-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #765
- Loading branch information
Showing
8 changed files
with
72 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package version | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
) | ||
|
||
// The git commit that was compiled. This will be filled in by the compiler. | ||
var GitCommit string | ||
var GitDescribe string | ||
|
||
// The main version number that is being run at the moment. | ||
const Version = "0.3.1" | ||
|
||
// A pre-release marker for the version. If this is "" (empty string) | ||
// then it means that it is a final release. Otherwise, this is a pre-release | ||
// such as "dev" (in development), "beta", "rc1", etc. | ||
const VersionPrerelease = "dev" | ||
|
||
// VersionInfo | ||
type VersionInfo struct { | ||
Revision string | ||
Version string | ||
VersionPrerelease string | ||
} | ||
|
||
func GetVersion() *VersionInfo { | ||
ver := Version | ||
rel := VersionPrerelease | ||
if GitDescribe != "" { | ||
ver = GitDescribe | ||
} | ||
if GitDescribe == "" && rel == "" && VersionPrerelease != "" { | ||
rel = "dev" | ||
} | ||
|
||
return &VersionInfo{ | ||
Revision: GitCommit, | ||
Version: ver, | ||
VersionPrerelease: rel, | ||
} | ||
} | ||
|
||
func (c *VersionInfo) String() string { | ||
var versionString bytes.Buffer | ||
|
||
fmt.Fprintf(&versionString, "Vault v%s", c.Version) | ||
if c.VersionPrerelease != "" { | ||
fmt.Fprintf(&versionString, "-%s", c.VersionPrerelease) | ||
|
||
if c.Revision != "" { | ||
fmt.Fprintf(&versionString, " (%s)", c.Revision) | ||
} | ||
} | ||
|
||
return versionString.String() | ||
} |