feat: add header diff command to show header differences#276
Conversation
The new command shows where the license headers of the invalid files differ from the license configured in the config file, to help understand why `header check` fails, e.g. to spot a typo in an existing license header. The texts are compared in the same normalized forms that the check command compares, so every difference shown is a real cause of the check failure. Resolves apache/skywalking#8002 Co-Authored-By: Claude Fable 5 <[email protected]>
kezhenxu94
left a comment
There was a problem hiding this comment.
Basically LGTM. One doubt, when there are regex patterns in the configured license pattern, are they printed as diff? Like if I set license pattern OK for skywalking-.* and the actual content is NK for skywalking-eyes, will the skywalking-eyes be a diff?
No — the regex pattern is never printed in the diff. I validated with your exact scenario. The diff is always computed against the normalized license content (
This is also covered in code: |
What's changed
Add a new subcommand
license-eye header diff [paths...](aliasd) that shows where the license headers of the invalid files differ from the license configured in the config file, to help understand whyheader checkfails, e.g. to spot a typo in an existing license header.Resolves apache/skywalking#8002.
Example
For a
test.gowhose license header has a typowwwhttp://www.apache.org/licenses/LICENSE-2.0in the license URL (the example in the original issue), and amissing.pywithout any license header:Design notes
header checkcompares insatisfy(), so every difference shown is a real cause of the check failure, instead of cosmetic noise such as comment style or line wrapping.[-text-]marks text expected by the configured license but missing in the file,{+text+}marks text in the file but not expected by the configured license, and long runs of unchanged/missing words are collapsed into....license header is found at normalized offset N, which exceeds the license-location-threshold M, move it closer to the file start.github.com/sergi/go-diff, which was already in the module graph (an indirect dependency via go-git), so it is only promoted from indirect to direct ingo.mod, no new dependency tree is introduced.modestraight through toheader ${mode}, somode: diffworks out of the box; only the doc strings of the twoaction.ymlfiles are updated.header checksemantics for CI usage.🤖 Generated with Claude Code