-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assemble 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. [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
- Loading branch information
1 parent
ad91191
commit bcd921b
Showing
3 changed files
with
246 additions
and
26 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
Oops, something went wrong.