Skip to content

Commit

Permalink
fix: don't set SourceCode field unless there is actually a commit
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jan 20, 2025
1 parent c3058a5 commit 899c503
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 53 deletions.
7 changes: 5 additions & 2 deletions extractor/filesystem/language/python/uvlock/uvlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ func (e Extractor) Extract(ctx context.Context, input *filesystem.ScanInput) ([]
Name: lockPackage.Name,
Version: lockPackage.Version,
Locations: []string{input.Path},
SourceCode: &extractor.SourceCodeIdentifier{
}

if commit != "" {
pkgDetails.SourceCode = &extractor.SourceCodeIdentifier{
Commit: commit,
},
}
}

depGroupVals := []string{}
Expand Down
51 changes: 0 additions & 51 deletions extractor/filesystem/language/python/uvlock/uvlock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "emoji",
Version: "2.14.0",
Locations: []string{"testdata/one-package.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -135,9 +132,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "emoji",
Version: "2.14.0",
Locations: []string{"testdata/two-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -146,9 +140,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "protobuf",
Version: "4.25.5",
Locations: []string{"testdata/two-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand Down Expand Up @@ -184,9 +175,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "emoji",
Version: "2.14.0",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -195,9 +183,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "click",
Version: "8.1.7",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{"cli"},
},
Expand All @@ -206,9 +191,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "colorama",
Version: "0.4.6",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -217,9 +199,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "black",
Version: "24.10.0",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{"dev", "test"},
},
Expand All @@ -228,9 +207,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "flake8",
Version: "7.1.1",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{"test"},
},
Expand All @@ -239,9 +215,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "mccabe",
Version: "0.7.0",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -250,9 +223,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "mypy-extensions",
Version: "1.0.0",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -261,9 +231,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "packaging",
Version: "24.2",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -272,9 +239,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "pathspec",
Version: "0.12.1",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -283,9 +247,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "platformdirs",
Version: "4.3.6",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -294,9 +255,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "pycodestyle",
Version: "2.12.1",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -305,9 +263,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "pyflakes",
Version: "3.2.0",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -316,9 +271,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "tomli",
Version: "2.2.1",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand All @@ -327,9 +279,6 @@ func TestExtractor_Extract(t *testing.T) {
Name: "typing-extensions",
Version: "4.12.2",
Locations: []string{"testdata/grouped-packages.lock"},
SourceCode: &extractor.SourceCodeIdentifier{
Commit: "",
},
Metadata: osv.DepGroupMetadata{
DepGroupVals: []string{},
},
Expand Down

0 comments on commit 899c503

Please sign in to comment.