Skip to content

diff: report declared license changes - #314

Merged
andrew merged 5 commits into
git-pkgs:mainfrom
abhinavgautam01:feature/diff-license-changes-304
Aug 10, 2026
Merged

andrew merged 5 commits into
git-pkgs:mainfrom
abhinavgautam01:feature/diff-license-changes-304

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

Closes #304

Summary

  • Report declared-license changes when comparing manifests with git pkgs diff-file.
  • Add a structured license_changes field to JSON diff output with manifest path and before/after license lists.
  • Emit deterministic license: ... lines from diff-driver so Git textconv can display license changes.
  • Deduplicate and sort declared licenses to avoid ordering-only differences.
  • Handle license additions and removals, including manifests without dependencies.
  • Document declared-license comparison and add focused text, JSON and textconv regression tests.

Verification

  • go build ./...
  • go test -race ./... -count=1
  • go mod tidy -diff
  • go tool golangci-lint run ./...
  • git diff --check

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds declared-license change detection to git pkgs diff-file and Git textconv output, enabling license additions/removals/changes to be surfaced alongside existing dependency diffs and in structured JSON.

Changes:

  • Extend diff results and text output to include declared license changes (license_changes in JSON + “Declared licenses:” section in text).
  • Parse and compare declared licenses in diff-file, with sorting/deduplication for deterministic output.
  • Emit deterministic license: ... lines from diff-driver and add targeted regression tests + documentation update.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Documents that diff-file also reports declared license changes for manifests.
cmd/diff.go Adds license_changes to diff result JSON schema and prints declared-license changes in text output.
cmd/diff_file.go Parses licenses from manifests and emits DeclaredLicenseChange entries when licenses differ.
cmd/diff_file_test.go Adds unit test coverage for license sorting/deduplication helper.
cmd/diff_driver.go Emits deterministic license: ... lines to support textconv diffs for license changes.
cmd/diff_driver_test.go Adds tests ensuring license lines are emitted and raw content is not emitted after license removal.
cmd/analysis_test.go Adds integration tests for diff-file declared-license output (text and JSON).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/diff_file.go Resolved

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two changes are still needed:

  • Sanitize declared license values before cmd/diff.go writes them to terminal output. manifests.Parse returns these values verbatim, so control sequences currently pass straight through. Add a regression test for control characters.
  • Split the added cmd/diff_driver_test.go subtests into separate test functions. They raise TestDiffDriver cognitive complexity from below the limit to 39, above the configured limit of 30.

@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

Fixed both requested changes.

  • formatDeclaredLicenses now sanitizes each declared-license value with the existing Sanitize helper before writing terminal output. I added regression coverage for ANSI escape and NUL control characters.
  • The two added diff-driver subtests are now separate top-level test functions, bringing the existing TestDiffDriver function back below the configured cognitive-complexity limit.

@andrew
andrew merged commit 2a49764 into git-pkgs:main Aug 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diff: report declared license changes

3 participants