mirror of https://github.com/knative/pkg.git
changeset: allow override the revision through ldflags (#2601)
The main reason for this is to support cases where the `go build` happens on a non git folder but we want to pass a revision anyway. Signed-off-by: Vincent Demeester <vincent@sbr.pm> Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
92ed919344
commit
dc1fae1337
|
@ -39,7 +39,10 @@ var (
|
|||
// The result will have a '-dirty' suffix if the workspace was not clean
|
||||
func Get() string {
|
||||
once.Do(func() {
|
||||
rev = get()
|
||||
if rev == "" {
|
||||
rev = get()
|
||||
}
|
||||
// It has been set through ldflags, do nothing
|
||||
})
|
||||
|
||||
return rev
|
||||
|
|
|
@ -73,6 +73,7 @@ func TestGet(t *testing.T) {
|
|||
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
rev = ""
|
||||
once = sync.Once{}
|
||||
readBuildInfo = func() (info *debug.BuildInfo, ok bool) {
|
||||
return c.info, c.ok
|
||||
|
|
Loading…
Reference in New Issue