Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: spdx/tools-golang
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.5.1
Choose a base ref
...
head repository: spdx/tools-golang
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.5.2
Choose a head ref
  • 4 commits
  • 6 files changed
  • 2 contributors

Commits on Jun 5, 2023

  1. build(deps): Bump github.com/stretchr/testify from 1.8.3 to 1.8.4

    Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.3 to 1.8.4.
    - [Release notes](https://github.com/stretchr/testify/releases)
    - [Commits](stretchr/testify@v1.8.3...v1.8.4)
    
    ---
    updated-dependencies:
    - dependency-name: github.com/stretchr/testify
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jun 5, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a6a5e23 View commit details

Commits on Jun 6, 2023

  1. fix duplicate shorthand relationships for opposite case

    Signed-off-by: Brandon Lum <lumjjb@gmail.com>
    lumjjb committed Jun 6, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    lumjjb Brandon Lum
    Copy the full SHA
    80032f1 View commit details
  2. Merge pull request #220 from spdx/fix-shorthand-dups-again

    fix duplicate shorthand relationships for opposite case
    lumjjb authored Jun 6, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e861b35 View commit details
  3. Merge pull request #219 from spdx/dependabot/go_modules/github.com/st…

    …retchr/testify-1.8.4
    
    build(deps): Bump github.com/stretchr/testify from 1.8.3 to 1.8.4
    lumjjb authored Jun 6, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4b477e8 View commit details
Showing with 49 additions and 17 deletions.
  1. +1 −1 go.mod
  2. +2 −2 go.sum
  3. +17 −1 spdx/v2/v2_2/document.go
  4. +6 −6 spdx/v2/v2_2/json/json_test.go
  5. +17 −1 spdx/v2/v2_3/document.go
  6. +6 −6 spdx/v2/v2_3/json/json_test.go
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ require (
github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092
github.com/google/go-cmp v0.5.9
github.com/spdx/gordf v0.0.0-20201111095634-7098f93598fb
github.com/stretchr/testify v1.8.3
github.com/stretchr/testify v1.8.4
sigs.k8s.io/yaml v1.3.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
18 changes: 17 additions & 1 deletion spdx/v2/v2_2/document.go
Original file line number Diff line number Diff line change
@@ -101,7 +101,23 @@ func (d *Document) UnmarshalJSON(b []byte) error {

relationshipExists := map[string]bool{}
serializeRel := func(r *Relationship) string {
return fmt.Sprintf("%v-%v->%v", common.RenderDocElementID(r.RefA), r.Relationship, common.RenderDocElementID(r.RefB))
refA := r.RefA
refB := r.RefB
rel := r.Relationship

// we need to serialize the opposite for CONTAINED_BY and DESCRIBED_BY
// so that it will match when we try to de-duplicate during deserialization.
switch r.Relationship {
case common.TypeRelationshipContainedBy:
rel = common.TypeRelationshipContains
refA = r.RefB
refB = r.RefA
case common.TypeRelationshipDescribeBy:
rel = common.TypeRelationshipDescribe
refA = r.RefB
refB = r.RefA
}
return fmt.Sprintf("%v-%v->%v", common.RenderDocElementID(refA), rel, common.RenderDocElementID(refB))
}

// index current list of relationships to ensure no duplication
12 changes: 6 additions & 6 deletions spdx/v2/v2_2/json/json_test.go
Original file line number Diff line number Diff line change
@@ -227,9 +227,9 @@ func Test_ShorthandFieldsNoDuplicates(t *testing.T) {
"relatedSpdxElement": "SPDXRef-File-1"
},
{
"spdxElementId": "SPDXRef-Package-1",
"relationshipType": "CONTAINS",
"relatedSpdxElement": "SPDXRef-File-2"
"spdxElementId": "SPDXRef-File-2",
"relationshipType": "CONTAINED_BY",
"relatedSpdxElement": "SPDXRef-Package-1"
}
]
}`
@@ -291,9 +291,9 @@ func Test_ShorthandFieldsNoDuplicates(t *testing.T) {
Relationship: common.TypeRelationshipContains,
},
{
RefA: id("Package-1"),
RefB: id("File-2"),
Relationship: common.TypeRelationshipContains,
RefA: id("File-2"),
RefB: id("Package-1"),
Relationship: common.TypeRelationshipContainedBy,
},
},
}
18 changes: 17 additions & 1 deletion spdx/v2/v2_3/document.go
Original file line number Diff line number Diff line change
@@ -100,7 +100,23 @@ func (d *Document) UnmarshalJSON(b []byte) error {

relationshipExists := map[string]bool{}
serializeRel := func(r *Relationship) string {
return fmt.Sprintf("%v-%v->%v", common.RenderDocElementID(r.RefA), r.Relationship, common.RenderDocElementID(r.RefB))
refA := r.RefA
refB := r.RefB
rel := r.Relationship

// we need to serialize the opposite for CONTAINED_BY and DESCRIBED_BY
// so that it will match when we try to de-duplicate during deserialization.
switch r.Relationship {
case common.TypeRelationshipContainedBy:
rel = common.TypeRelationshipContains
refA = r.RefB
refB = r.RefA
case common.TypeRelationshipDescribeBy:
rel = common.TypeRelationshipDescribe
refA = r.RefB
refB = r.RefA
}
return fmt.Sprintf("%v-%v->%v", common.RenderDocElementID(refA), rel, common.RenderDocElementID(refB))
}

// index current list of relationships to ensure no duplication
12 changes: 6 additions & 6 deletions spdx/v2/v2_3/json/json_test.go
Original file line number Diff line number Diff line change
@@ -245,9 +245,9 @@ func Test_ShorthandFieldsNoDuplicates(t *testing.T) {
"relatedSpdxElement": "SPDXRef-File-1"
},
{
"spdxElementId": "SPDXRef-Package-1",
"relationshipType": "CONTAINS",
"relatedSpdxElement": "SPDXRef-File-2"
"spdxElementId": "SPDXRef-File-2",
"relationshipType": "CONTAINED_BY",
"relatedSpdxElement": "SPDXRef-Package-1"
}
]
}`
@@ -309,9 +309,9 @@ func Test_ShorthandFieldsNoDuplicates(t *testing.T) {
Relationship: common.TypeRelationshipContains,
},
{
RefA: id("Package-1"),
RefB: id("File-2"),
Relationship: common.TypeRelationshipContains,
RefA: id("File-2"),
RefB: id("Package-1"),
Relationship: common.TypeRelationshipContainedBy,
},
},
}