Skip to content

Commit 124c558

Browse files
committed
fix(cli): add buildinfo.GitCommit to query cache key (#8159)
### Changes are visible to end-users: no ### Test plan - Covered by existing test cases GitOrigin-RevId: b978314e45722293228ca2ef20c185b696faf093
1 parent 6ae0d51 commit 124c558

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

gazelle/js/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ go_library(
2121
importpath = "github.com/aspect-build/aspect-cli/gazelle/js",
2222
visibility = ["//visibility:public"],
2323
deps = [
24+
"//buildinfo",
2425
"//gazelle/common",
2526
"//gazelle/common/cache",
2627
"//gazelle/common/git",

gazelle/js/generate.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"strings"
2828
"sync"
2929

30+
"github.com/aspect-build/aspect-cli/buildinfo"
3031
gazelle "github.com/aspect-build/aspect-cli/gazelle/common"
3132
"github.com/aspect-build/aspect-cli/gazelle/common/cache"
3233
starlark "github.com/aspect-build/aspect-cli/gazelle/common/starlark"
@@ -858,7 +859,15 @@ func init() {
858859
func computeCacheKey(content []byte) (string, bool) {
859860
cacheDigest := crypto.MD5.New()
860861

862+
if buildinfo.IsStamped() {
863+
if _, err := cacheDigest.Write([]byte(buildinfo.GitCommit)); err != nil {
864+
BazelLog.Errorf("Failed to write GitCommit to cache digest: %v", err)
865+
return "", false
866+
}
867+
}
868+
861869
if _, err := cacheDigest.Write(content); err != nil {
870+
BazelLog.Errorf("Failed to write source to cache digest: %v", err)
862871
return "", false
863872
}
864873

0 commit comments

Comments
 (0)