-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Remove baseapp dependency on the version package #4250
Merged
alessio
merged 6 commits into
master
from
alessio/gaia-split-prep-remove-baseapp-dep-on-version-pkg
May 2, 2019
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
36d03c5
Remove baseapp dependency on the version package
alessio 9362ea5
Add pending entries
alessio d4feb47
Don't append \n to version.GoVersion
alessio 66668fa
Better package docs
alessio 571a49d
Move SetAppVersion() to options.go
alessio 9d5d101
Add sealing test for appVersion
alessio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#4250 BaseApp.Query() returns app's version string set via BaseApp.SetAppVersion() | ||
when handling /app/version queries instead of the version string passed as build | ||
flag at compile time. |
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 @@ | ||
#4250 New BaseApp.{,Set}AppVersion() methods to get/set app's version string. |
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
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 |
---|---|---|
@@ -1,40 +1,62 @@ | ||
//nolint | ||
// This package is a convenience utility that provides SDK | ||
// consumers with a ready-to-use version command that | ||
// produces apps versioning information based on flags | ||
// passed at compile time. | ||
// | ||
// Configure the version command | ||
// | ||
// The version command can be just added to your cobra root command. | ||
// At build time, the variables Name, Version, Commit, GoSumHash, and | ||
// BuildTags can be passed as build flags as shown in the following | ||
// example: | ||
// | ||
// go build -X github.com/cosmos/cosmos-sdk/version.Name=dapp \ | ||
// -X github.com/cosmos/cosmos-sdk/version.Version=1.0 \ | ||
// -X github.com/cosmos/cosmos-sdk/version.Commit=f0f7b7dab7e36c20b757cebce0e8f4fc5b95de60 \ | ||
// -X "github.com/cosmos/cosmos-sdk/version.BuildTags=linux darwin amd64" | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
// Variables set by build flags | ||
var ( | ||
Commit = "" | ||
Version = "" | ||
// Application's name | ||
Name = "" | ||
// Application's version string | ||
Version = "" | ||
// Commit | ||
Commit = "" | ||
// Hash of the go.sum file | ||
GoSumHash = "" | ||
// Build tags | ||
BuildTags = "" | ||
) | ||
|
||
type versionInfo struct { | ||
CosmosSDK string `json:"cosmos_sdk"` | ||
Name string `json:"name"` | ||
Version string `json:"version"` | ||
GitCommit string `json:"commit"` | ||
GoSumHash string `json:"gosum_hash"` | ||
BuildTags string `json:"build_tags"` | ||
GoVersion string `json:"go"` | ||
} | ||
|
||
func (v versionInfo) String() string { | ||
return fmt.Sprintf(`cosmos-sdk: %s | ||
return fmt.Sprintf(`%s: %s | ||
git commit: %s | ||
go.sum hash: %s | ||
build tags: %s | ||
%s`, v.CosmosSDK, v.GitCommit, v.GoSumHash, v.BuildTags, v.GoVersion) | ||
%s`, v.Name, v.Version, v.GitCommit, v.GoSumHash, v.BuildTags, v.GoVersion) | ||
} | ||
|
||
func newVersionInfo() versionInfo { | ||
return versionInfo{ | ||
Name, | ||
Version, | ||
Commit, | ||
GoSumHash, | ||
BuildTags, | ||
fmt.Sprintf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)} | ||
fmt.Sprintf("go version %s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 PR should probably show an example for how the
gaia
Name is set here (within thecmd/gaia
) - I'm assuming you just forgot thisThere 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.
I did not: https://github.com/cosmos/cosmos-sdk/pull/4250/files#diff-b67911656ef5d18c4ae36cb6741b7965R47
All these variables are set via build flags. I didn't provide examples as there were any before.
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.
I've improved the version package docs