Skip to content

Return declared licenses from ParseResult - #50

Open
abhinavgautam01 wants to merge 2 commits into
git-pkgs:mainfrom
abhinavgautam01:feat/49-declared-license
Open

Return declared licenses from ParseResult#50
abhinavgautam01 wants to merge 2 commits into
git-pkgs:mainfrom
abhinavgautam01:feat/49-declared-license

Conversation

@abhinavgautam01

@abhinavgautam01 abhinavgautam01 commented Jul 30, 2026

Copy link
Copy Markdown

Closes #49

Summary

Add declared license metadata to ParseResult, allowing consumers to access license information directly from supported package manifests.

This introduces:

  • Licenses []string for raw declared license values
  • LicenseFile string for a manifest-relative license file
  • setup.cfg and OPAM manifest support
  • Documentation and regression tests for the new fields

License values are returned without SPDX normalization, keeping this package independent of github.com/git-pkgs/spdx.

Supported formats

License metadata is extracted from:

  • package.json and bower.json
  • Cargo.toml
  • pyproject.toml, setup.py, and setup.cfg
  • *.gemspec
  • *.podspec
  • composer.json
  • pom.xml
  • *.nuspec
  • *.cabal
  • R DESCRIPTION
  • mix.exs
  • opam and *.opam
  • elm.json and elm-package.json

Formats without declared license fields, such as go.mod and pubspec.yaml, continue to return empty values.

For formats that allow multiple license files, LicenseFile contains the first declared path, matching the singular public API proposed in the issue.

Validation

  • gofmt
  • git diff --check
  • go build ./...
  • go vet ./...
  • go test ./...
  • go test -race ./...
  • golangci-lint — 0 issues

Follow-up hardening

A second review added coverage and fixes for:

  • Package-style and application-style elm.json dependencies
  • Comma-containing setup.cfg license values and version constraints
  • One-line Elixir package/0 declarations
  • Whitespace-tolerant NuSpec license types

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.

Return declared licence from ParseResult

1 participant