mirror of
https://github.com/miniflux/v2.git
synced 2025-08-26 18:21:01 +00:00
fix(version): allow build info to be set with LDFLAGS and fallback to VCS metadata when available
This commit is contained in:
parent
a010544200
commit
6bf3b3c464
1 changed files with 18 additions and 4 deletions
|
@ -7,11 +7,11 @@ import (
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Variables populated at build time.
|
// Variables populated at build time when using LD_FLAGS.
|
||||||
var (
|
var (
|
||||||
Version = "Development Version"
|
Version = ""
|
||||||
Commit = getCommit()
|
Commit = ""
|
||||||
BuildDate = getBuildDate()
|
BuildDate = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
func getCommit() string {
|
func getCommit() string {
|
||||||
|
@ -38,3 +38,17 @@ func getBuildDate() string {
|
||||||
}
|
}
|
||||||
return "Unknown (built outside VCS)"
|
return "Unknown (built outside VCS)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate build information from VCS metadata if LDFLAGS are not set.
|
||||||
|
// Falls back to values from the Go module's build info when available.
|
||||||
|
func init() {
|
||||||
|
if Version == "" {
|
||||||
|
Version = "Development Version"
|
||||||
|
}
|
||||||
|
if Commit == "" {
|
||||||
|
Commit = getCommit()
|
||||||
|
}
|
||||||
|
if BuildDate == "" {
|
||||||
|
BuildDate = getBuildDate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue