Is it possible to add a version number using git / github

前端 未结 5 1364
逝去的感伤
逝去的感伤 2020-12-08 20:04

I\'m using Github, and realized they have a nice little api for accessing repo information like commits, who did it, etc.

This would be a great way to show previous

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 20:43

    There are two kinds tags to consider, a build number and a version number. A version number can be applied as a tag by a person when the product ships. This tag is historical and identifies significant events (e.g. shipping the product).

    The build number is useful for identifying which build you are on relative to some starting point. The combination of git-tag and git-describe provide a nice means of generating a build number that can be embedded into a build. git-describe can locate a specific previous tag with a glob pattern. The results of git describe will be formatted as:

    tagname-[0-9]+-g[0-9a-f]+
    

    Where the first pattern is the number of commits from the tag and the second pattern is the hash of the current commit. This can be nicely formatted into a build number. Including the hash (at least the first 7 characters) makes it simple to identify the specific commit associated with the build.

    For example, git describe could return release-2.2-42-gd788e0e. This could be formatted to become release-2.2 build 42 (d788e0e).

提交回复
热议问题