@@ -25,23 +25,39 @@ set -euo pipefail
2525
2626# ==============================================================================
2727
28- EXCLUDED_FILES=(
29- " .devcontainer/devcontainer.json"
30- " .pre-commit-hooks.yaml"
31- " .tool-versions"
32- " .vscode/extensions.json"
33- " infrastructure/terraform/bin/terraform.sh"
34- " Makefile"
35- " project.code-workspace"
36- " src/jekyll-devcontainer/src/.devcontainer/devcontainer.json"
37- )
38-
39- EXCLUDED_DIRS=(
40- " .git/"
41- " .venv/"
42- " docs/"
43- " node_modules/"
44- )
28+ CONFIG_FILE=" scripts/config/check-todos-ignore.conf"
29+
30+ # Arrays to be populated from config file
31+ EXCLUDED_FILES=()
32+ EXCLUDED_DIRS=()
33+
34+
35+ # Load exclusions from configuration file
36+ function load_exclusions_from_config() {
37+ local config_file=" $1 "
38+ local section=" "
39+
40+ while IFS= read -r line || [ -n " $line " ]; do
41+ # Skip empty lines and comments
42+ [[ -z " $line " || " $line " =~ ^[[:space:]]* # ]] && continue
43+
44+ # Check for section headers
45+ if [[ " $line " =~ ^\[ ([^]]+)\] $ ]]; then
46+ section=" ${BASH_REMATCH[1]} "
47+ continue
48+ fi
49+
50+ # Add entries to appropriate arrays based on current section
51+ case " $section " in
52+ files)
53+ EXCLUDED_FILES+=(" $line " )
54+ ;;
55+ directories)
56+ EXCLUDED_DIRS+=(" $line " )
57+ ;;
58+ esac
59+ done < " $config_file "
60+ }
4561
4662
4763# Get files to check based on mode
@@ -69,12 +85,7 @@ function get_files_to_check() {
6985
7086
7187function build_exclude_args() {
72- local args=(
73- --exclude=" .github/actions/check-todo-usage/action.yaml"
74- --exclude=" .github/workflows/stage-1-commit.yaml"
75- --exclude=" scripts/config/pre-commit.yaml"
76- --exclude=" scripts/githooks/check-todos.sh"
77- ) # Exclude this script and its references by default, as it naturally contains TODOs. Todo todo todo <- see?
88+ local args=() # Exclusions are now loaded from config file
7889
7990 if [ ${# EXCLUDED_DIRS[@]} -gt 0 ]; then
8091 for dir in " ${EXCLUDED_DIRS[@]} " ; do
@@ -204,6 +215,9 @@ function print_output() {
204215function main() {
205216 cd " $( git rev-parse --show-toplevel) "
206217
218+ # Load exclusions from config file
219+ load_exclusions_from_config " $CONFIG_FILE "
220+
207221 local check_mode=" ${check:- working-tree-changes} "
208222 local exclude_args=$( build_exclude_args)
209223 local todos=$( search_todos " $check_mode " $exclude_args )
0 commit comments