fix(repo): preserve RepoMetadata on FS cache hit (#9389)

This commit is contained in:
DmitriyLewen
2025-08-27 17:08:22 +06:00
committed by GitHub
parent 9594d63f2b
commit 4f2a44ea45
2 changed files with 14 additions and 4 deletions

View File

@@ -190,10 +190,11 @@ func (a Artifact) Inspect(ctx context.Context) (artifact.Reference, error) {
// Cache hit
a.logger.DebugContext(ctx, "Cache hit", log.String("key", cacheKey))
return artifact.Reference{
Name: cmp.Or(a.artifactOption.Original, a.rootPath),
Type: a.artifactOption.Type,
ID: cacheKey,
BlobIDs: []string{cacheKey},
Name: cmp.Or(a.artifactOption.Original, a.rootPath),
Type: a.artifactOption.Type,
ID: cacheKey,
BlobIDs: []string{cacheKey},
RepoMetadata: a.repoMetadata,
}, nil
}
}

View File

@@ -276,6 +276,15 @@ func TestArtifact_Inspect(t *testing.T) {
BlobIDs: []string{
"sha256:dc7c6039424c9fce969d3c2972d261af442a33f13e7494464386dbe280612d4c",
},
RepoMetadata: artifact.RepoMetadata{
RepoURL: "https://github.com/aquasecurity/trivy-test-repo/",
Branch: "main",
Tags: []string{"v0.0.1"},
Commit: "8a19b492a589955c3e70c6ad8efd1e4ec6ae0d35",
CommitMsg: "Update README.md",
Author: "Teppei Fukuda <knqyf263@gmail.com>",
Committer: "GitHub <noreply@github.com>",
},
},
wantBlobInfo: &types.BlobInfo{
SchemaVersion: types.BlobJSONSchemaVersion,