mirror of
https://github.com/vee1e/gittuf.git
synced 2026-09-03 11:17:08 +00:00
23 lines
482 B
Go
23 lines
482 B
Go
// Copyright The gittuf Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package version
|
|
|
|
import "runtime/debug"
|
|
|
|
// gitVersion records the basic version information from Git. It is typically
|
|
// overwritten during a go build.
|
|
var gitVersion = "devel"
|
|
|
|
func GetVersion() string {
|
|
buildInfo, ok := debug.ReadBuildInfo()
|
|
if !ok {
|
|
return "unknown"
|
|
}
|
|
|
|
if buildInfo.Main.Version == "(devel)" || buildInfo.Main.Version == "" {
|
|
return gitVersion
|
|
}
|
|
|
|
return buildInfo.Main.Version
|
|
}
|