fix: LICENSE file no longer updated on every run when no headers changed#224
Merged
Conversation
anyFileUpdated was unconditionally set to true in non-plan mode due to a tautological condition, causing the LICENSE year to be bumped on every run even when all source file headers were already correct. This triggered spurious pre-commit hook failures. Fix: teach addlicense.Run to return whether it actually wrote any files, and use that signal instead of the always-true condition.
sonamtenzin2
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
anyFileUpdatedwas unconditionally set totruein non-plan mode due to a Repetitive condition, causing the LICENSE year to be bumped on every run even when all source file headers were already correct. This triggered buggy pre-commit hook failures.Fix: teach
addlicense.Runto return whether it actually wrote any files, and use that signal instead of the always-true condition.🛠️ Description
What was broken:
The
anyFileUpdatedflag incmd/headers.gowas supposed to betrueonly when at least one source file was actually modified. The condition guarding it was a tautology — the second branch(!plan && runErr == nil)is always true in normal mode, soanyFileUpdatedwas set on every successful run regardless of whether any file was touched. This caused the LICENSE file's copyright year to be bumped unconditionally, producing a spurious git diff and causing pre-commit hooks to fail with "files were modified by this hook" even when no header work was needed.What changed:
addlicense.processFilenow returns(bool, error)— the bool istruewhen the file was actually written toaddlicense.Runnow returns(bool, error)— uses anatomic.Boolto aggregate results across parallel goroutinescmd/headers.gois replaced with the actual signal fromRunBefore:
After:
🔗 External Links
👍 Definition of Done
New functionality works? — verified: repo with all correct headers produces zero changes and clean git status
Tests added? — existing test suite updated to match new return signature; all packages pass
🤔 Can be merged upon approval?
✅
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request. — simple git revert; no schema or data changes involved.
If applicable, I've documented the impact of any changes to security controls. — no security controls affected; bug fix in copyright year tracking logic only.
Test Results
--planmode with missing header--planmode with everything correctignore_year1=true, single-year headers already correct