Problem
The automated cleanup workflow (.github/workflows/cleanup.yml) is incorrectly flagging and removing files that are listed in .cleanup-ignore. The PR body template mentions .cleanup-ignore as a way to exclude files from future scans, but the actual shell script logic never reads this file.
This was observed in PR #422, where scripts/pre-commit-hook.sh was marked for deletion despite being listed in .cleanup-ignore.
Root Cause
In the Detect unused scripts step of cleanup.yml, only two files are hardcoded as explicit exceptions:
if [ "${refs}" -eq 0 ] && \
[ "${script_name}" != "quality_gate.sh" ] && \
[ "${script_name}" != "setup-hooks.sh" ]; then
# marked as unused
fi
There is zero logic to read .cleanup-ignore. The mention of this file in the PR body is misleading documentation that was never implemented.
Expected Behavior
- If a
.cleanup-ignore file exists at the repository root, the workflow should read it line by line.
- Any file whose basename (or relative path) matches an entry in
.cleanup-ignore should be excluded from the unused-file detection.
- Lines starting with
# and empty lines should be treated as comments/ignored.
Proposed Fix
At the top of the Detect unused scripts step, add the following logic:
# Load .cleanup-ignore entries
ignored_files=()
if [ -f ".cleanup-ignore" ]; then
while IFS= read -r line || [[ -n "$line" ]]; do
# Skip comments and empty lines
[[ "$line" =~ ^#.*$ || -z "$line" ]] && continue
ignored_files+=("$(basename "$line")")
done < ".cleanup-ignore"
fi
Then inside the for script in scripts/*.sh loop, add a skip check before marking files as unused:
# Check if the file is in .cleanup-ignore
skip=false
for ignored in "${ignored_files[@]}"; do
[ "$script_name" = "$ignored" ] && skip=true && break
done
[ "$skip" = true ] && continue
Acceptance Criteria
Related
Problem
The automated cleanup workflow (
.github/workflows/cleanup.yml) is incorrectly flagging and removing files that are listed in.cleanup-ignore. The PR body template mentions.cleanup-ignoreas a way to exclude files from future scans, but the actual shell script logic never reads this file.This was observed in PR #422, where
scripts/pre-commit-hook.shwas marked for deletion despite being listed in.cleanup-ignore.Root Cause
In the
Detect unused scriptsstep ofcleanup.yml, only two files are hardcoded as explicit exceptions:There is zero logic to read
.cleanup-ignore. The mention of this file in the PR body is misleading documentation that was never implemented.Expected Behavior
.cleanup-ignorefile exists at the repository root, the workflow should read it line by line..cleanup-ignoreshould be excluded from the unused-file detection.#and empty lines should be treated as comments/ignored.Proposed Fix
At the top of the
Detect unused scriptsstep, add the following logic:Then inside the
for script in scripts/*.shloop, add a skip check before marking files as unused:Acceptance Criteria
.cleanup-ignorefile is read at the start of the detection step.cleanup-ignoreare never added to the unused-files list# ...) and blank lines in.cleanup-ignoreare gracefully ignored.cleanup-ignore.cleanup-ignoreRelated
scripts/pre-commit-hook.sh.github/workflows/cleanup.yml