wu-sheng opened a new pull request, #276:
URL: https://github.com/apache/skywalking-eyes/pull/276

   ## What's changed
   
   Add a new subcommand `license-eye header diff [paths...]` (alias `d`) that 
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.
   
   Resolves apache/skywalking#8002.
   
   ### Example
   
   For a `test.go` whose license header has a typo 
`wwwhttp://www.apache.org/licenses/LICENSE-2.0` in the license URL (the example 
in the original issue), and a `missing.py` without any license header:
   
   ```
   INFO Loading configuration from file: .licenserc.yaml
   missing.py:
        [-licensed to the asf under one or more contributor license ... the 
specific language governing permissions and limitations under the license.-] ...
   test.go:
        ... copy of the license at 
[-http://www.apache.org/licenses/license-2.0-] 
{+wwwhttp://www.apache.org/licenses/license-2.0+} unless required by applicable 
law ... and limitations under the license. ...
   INFO Totally checked 3 files, valid: 0, invalid: 2, ignored: 1, fixed: 0
   ERROR one or more files does not have a valid license header
   exit status 1
   ```
   
   ### Design notes
   
   - The texts are compared in their **normalized** forms (comment markers 
stripped, whitespace flattened, case-insensitive, etc.), the same forms that 
`header check` compares in `satisfy()`, 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 `...`.
   - A header that matches the license but sits too far into the file gets a 
precise message instead of a diff: `license header is found at normalized 
offset N, which exceeds the license-location-threshold M, move it closer to the 
file start`.
   - The word-level diff is built on `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 in `go.mod`, no new dependency tree is 
introduced.
   - The GitHub Action passes `mode` straight through to `header ${mode}`, so 
`mode: diff` works out of the box; only the doc strings of the two `action.yml` 
files are updated.
   - The exit code is non-zero when any file has an invalid header, matching 
the `header check` semantics for CI usage.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to