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:
A highly extensible Git implementation in pure Go.
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 in go-git has not been implemented yet. See the full compatibility comparison documentation with Git as well as the proposed Git describe command implementation for more details.
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, thego-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.