-
Notifications
You must be signed in to change notification settings - Fork 7
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
App version with pure Go Git and SemVer libraries #93
Merged
arcticicestudio
merged 2 commits into
epic/gh-33-the-way-to-go
from
improvement/gh-92-app-version-pure-go-git-and-semver-libs
Oct 18, 2019
Merged
App version with pure Go Git and SemVer libraries #93
arcticicestudio
merged 2 commits into
epic/gh-33-the-way-to-go
from
improvement/gh-92-app-version-pure-go-git-and-semver-libs
Oct 18, 2019
Conversation
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
Previously the version of the application was determined by calling `git` commands in a new shell process. This works in most cases, but might fail if Git is not installed on the running system. To prevent further enlargement of the required development environment setup dependencies by adding more checks for external dependencies, the `go-git` library v4 [1] (`github.com/src-d/go-git/v4`) has been added: "A highly extensible Git implementation in pure Go" It allows to interact with the project repository and extrac required information like the latest tag and commit of the current branch to assemble the application version. To simplify the processing and parsing of the version, the `semver` library v3 [2] (`github.com/Masterminds/semver/v3`) has also been added. The new `getAppVersionFromGit()` function assembles the version of the application from the metadata of the Git repository. It searches for the latest "SemVer" [3] compatible version tag in the current branch and falls back to the default version from the application configuration if none is found. If at least one tag is found but it is not the latest commit of the current branch, the build metadata will be appended, consisting of the amount of commits ahead and the shortened reference hash (8 digits) of the latest commit from the current branch. The function is a early implementation of the Git `describe` command because support in `go-git` [1] has not been implemented yet. See the full compatibility comparison documentation with Git [4] as well as the proposed Git `describe` command implementation [5] for more details. [1]: https://github.com/src-d/go-git/v4 [2]: https://github.com/Masterminds/semver/v3 [3]: https://semver.org [4]: https://github.com/src-d/go-git/blob/master/COMPATIBILITY.md [5]: src-d/go-git#816 Epic GH-33 GH-92
arcticicestudio
changed the base branch from
develop
to
epic/gh-33-the-way-to-go
October 17, 2019 20:20
…data The function implemented in the parent commit returned a string which results in loss of addiional data when used for other tasks. To allow to use the version metadata for other tasks, like adding more information to the compiled binary artifact, the function now returns a custom struct that is composed of a `semver.Version` struct and additional fields that stores Git related information: - `GitCommitHash` (type `plumbing.Hash`) - The latest commit hash of the current branch. - `GitCommitsAhead` (type `int`) - The count of commits ahead to the latest Git tag from the current branch. - `GitLatestVersionTag` (type `plumbing.Reference`) - The latest Git version tag in the current branch. Epic GH-33 GH-92
svengreb
approved these changes
Oct 18, 2019
arcticicestudio
deleted the
improvement/gh-92-app-version-pure-go-git-and-semver-libs
branch
October 18, 2019 11:18
This was referenced Oct 18, 2019
svengreb
pushed a commit
that referenced
this pull request
Oct 18, 2019
Previously the `info` command printed more detailed application information compared to the compact and machine-friendly `--version` global flag. The name of command was not optimal as it could give the impression that it provides more "info"rmation about one or more snowblocks that might be passed as argument(s). Therefore the command has been renamed to `version` which also matches the naming of many other Go CLI apps like Kubernetes [1] `kubectl` [2]. To also enhance the provided information the command now prints more application version details using the function implemented in GH-93. [1]: https://kubernetes.io [2]: https://github.com/kubernetes/kubernetes/tree/master/pkg/kubectl Epic GH-33 Relates to GH-93 GH-94
arcticicestudio
added a commit
that referenced
this pull request
Oct 18, 2019
Previously the `info` command printed more detailed application information compared to the compact and machine-friendly `--version` global flag. The name of command was not optimal as it could give the impression that it provides more "info"rmation about one or more snowblocks that might be passed as argument(s). Therefore the command has been renamed to `version` which also matches the naming of many other Go CLI apps like Kubernetes [1] `kubectl` [2]. To also enhance the provided information the command now prints more application version details using the function implemented in GH-93. [1]: https://kubernetes.io [2]: https://github.com/kubernetes/kubernetes/tree/master/pkg/kubectl Epic GH-33 Relates to GH-93 Resolves GH-94
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Resolves #92