6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-04 19:09:45 +00:00

Move the version metadata to cfg packageThis way it can be used by multiple binaries.

This commit is contained in:
Grzegorz Dlugoszewski
2020-06-12 20:56:34 +02:00
parent 33ca245d3a
commit c71ebea2d4
3 changed files with 36 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
package cfg
import (
"fmt"
"path"
"strings"
@@ -37,6 +38,23 @@ const (
OutSimple = "simple"
)
// Version metadata set by ldflags during the build.
var (
version string
commit string
date string
)
// Version returns a string with version metadata: version number, git sha and build date.
// It returns "development" if version variables are not set during the build.
func Version() string {
if version == "" {
return "development"
}
return fmt.Sprintf("%s - revision %s built at %s", version, commit[:6], date)
}
// gitconfig provides methods for looking up configiration values inside .gitconfig file
type gitconfig struct {
*config.Config