-
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 #92
Labels
Milestone
Comments
arcticicestudio
added a commit
that referenced
this issue
Oct 17, 2019
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 title
Assemble app version with pure Go Git and SemVer libraries
App version with pure Go Git and SemVer libraries
Oct 17, 2019
svengreb
pushed a commit
that referenced
this issue
Oct 18, 2019
…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
arcticicestudio
added a commit
that referenced
this issue
Oct 18, 2019
App version with pure Go Git and SemVer libraries 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. The function returned a composed struct to store application version information and metadata that allows to use the version metadata for other tasks. It consists of a embedded `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. [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 Resolves GH-92
This was referenced Oct 18, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Currently the version of the application is 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 (github.com/src-d/go-git/v4
) will be added:It allows to interact with the project repository and extract 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 (github.com/Masterminds/semver/v3
) will also be added.A new function will assemble the version of the application from the metadata of the Git repository.
It will search for the latest SemVer compatible version tag in the current branch and will fall 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 will be an early implementation of the Git
describe
command because support ingo-git
has not been implemented yet. See the full compatibility comparison documentation with Git as well as the proposed Gitdescribe
command implementation for more details.The text was updated successfully, but these errors were encountered: