Skip to content
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

Commits on Oct 17, 2019

  1. 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
    arcticicestudio committed Oct 17, 2019
    Configuration menu
    Copy the full SHA
    bcd921b View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2019

  1. Use composed struct to store application version information and meta…

    …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 committed Oct 18, 2019
    Configuration menu
    Copy the full SHA
    d1b5f25 View commit details
    Browse the repository at this point in the history