-
Notifications
You must be signed in to change notification settings - Fork 103
Add tag
& commit_hash
field to GetInfo
response
#1034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,16 @@ message GetInfoRequest { | |
} | ||
|
||
message GetInfoResponse { | ||
// The version of the LiTd software that the node is running. | ||
// The application version of the LiTd software running on the node, | ||
// following the Semantic Versioning 2.0.0 specification | ||
// (http://semver.org/). | ||
string version = 1; | ||
|
||
// The Git tag that the LiTd binary build was based on. If the build was | ||
// not based on a clean tagged commit, this field will contain the most | ||
// recent tag suffixed by the commit hash, and/or a "-dirty" suffix. | ||
string tag = 2; | ||
|
||
// The Git commit hash the LiTd binary build was based on. | ||
string commit_hash = 3; | ||
Comment on lines
+65
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps the MVP here is to just add this |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,17 @@ import ( | |
"strings" | ||
) | ||
|
||
// Commit stores the current commit hash of this build, this should be set | ||
// using the -ldflags during compilation. | ||
// Commit stores the current git tag of this build, when the build is based on | ||
// a tagged commit. If the build is based on an untagged commit or is a dirty | ||
// build, the Commit field stores the most recent tag suffixed by the commit | ||
// hash, and/or "-dirty". This should be set using the -ldflags during | ||
// compilation. | ||
var Commit string | ||
|
||
// GitCommitHash stores the current git commit hash of this build. This should | ||
// be set using the -ldflags during compilation. | ||
var GitCommitHash string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggest just "CommitHash" |
||
|
||
// semanticAlphabet | ||
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-." | ||
|
||
|
@@ -33,6 +40,31 @@ const ( | |
// Version returns the application version as a properly formed string per the | ||
// semantic versioning 2.0.0 spec (http://semver.org/). | ||
func Version() string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a breaking change no? should we not leave version behaviour as is? |
||
return semanticVersion() | ||
} | ||
|
||
// RichVersion returns the application version as a properly formed string | ||
// per the semantic versioning 2.0.0 spec (http://semver.org/), the git tag and | ||
// commit hash it was built on. | ||
func RichVersion() string { | ||
// Append git tag and commit hash of current build to version. | ||
return fmt.Sprintf( | ||
"%s tag=%s commit=%s", semanticVersion(), Commit, GitCommitHash, | ||
) | ||
} | ||
|
||
// CommitHash returns the git commit hash of the current build. | ||
func CommitHash() string { | ||
return GitCommitHash | ||
} | ||
|
||
// CommitTag returns the git tag of the current build. | ||
func CommitTag() string { | ||
return Commit | ||
} | ||
Comment on lines
+56
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are these functions? I'd say just use the globals directly. The reason |
||
|
||
// semanticVersion returns the SemVer part of the version. | ||
func semanticVersion() string { | ||
// Start with the major, minor, and patch versions. | ||
version := fmt.Sprintf("%d.%d.%d", appMajor, appMinor, appPatch) | ||
|
||
|
@@ -45,9 +77,6 @@ func Version() string { | |
version = fmt.Sprintf("%s-%s", version, preRelease) | ||
} | ||
|
||
// Append commit hash of current build to version. | ||
version = fmt.Sprintf("%s commit=%s", version, Commit) | ||
|
||
return version | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a breaking change - think let's leave this behaviour as is so it matches that of all the other binaries