Skip to content

Commit 4f2a44e

Browse files
authored
fix(repo): preserve RepoMetadata on FS cache hit (#9389)
1 parent 9594d63 commit 4f2a44e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

pkg/fanal/artifact/local/fs.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ func (a Artifact) Inspect(ctx context.Context) (artifact.Reference, error) {
190190
// Cache hit
191191
a.logger.DebugContext(ctx, "Cache hit", log.String("key", cacheKey))
192192
return artifact.Reference{
193-
Name: cmp.Or(a.artifactOption.Original, a.rootPath),
194-
Type: a.artifactOption.Type,
195-
ID: cacheKey,
196-
BlobIDs: []string{cacheKey},
193+
Name: cmp.Or(a.artifactOption.Original, a.rootPath),
194+
Type: a.artifactOption.Type,
195+
ID: cacheKey,
196+
BlobIDs: []string{cacheKey},
197+
RepoMetadata: a.repoMetadata,
197198
}, nil
198199
}
199200
}

pkg/fanal/artifact/repo/git_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ func TestArtifact_Inspect(t *testing.T) {
276276
BlobIDs: []string{
277277
"sha256:dc7c6039424c9fce969d3c2972d261af442a33f13e7494464386dbe280612d4c",
278278
},
279+
RepoMetadata: artifact.RepoMetadata{
280+
RepoURL: "https://github.com/aquasecurity/trivy-test-repo/",
281+
Branch: "main",
282+
Tags: []string{"v0.0.1"},
283+
Commit: "8a19b492a589955c3e70c6ad8efd1e4ec6ae0d35",
284+
CommitMsg: "Update README.md",
285+
Author: "Teppei Fukuda <[email protected]>",
286+
Committer: "GitHub <[email protected]>",
287+
},
279288
},
280289
wantBlobInfo: &types.BlobInfo{
281290
SchemaVersion: types.BlobJSONSchemaVersion,

0 commit comments

Comments
 (0)