diff options
author | Xi Ruoyao <xry111@mengyan1223.wang> | 2021-05-01 20:57:42 +0800 |
---|---|---|
committer | Xi Ruoyao <xry111@mengyan1223.wang> | 2021-05-01 21:00:30 +0800 |
commit | 6ca780c12dc8d1257a6a6ab0665f11d00de99fe3 (patch) | |
tree | 37f0bd848ab947330b5902fac88f0fcce9198429 | |
parent | 2013a74b0d3c1733c761254a03108e0606f7e396 (diff) |
git-version: simplify the versioning scheme
Now the version for trunk head is simply rx.y-z. x.y is the last
release, and z is the number of commits after x.y.
For other commits, the version is rx.y-z-g{sha}. An abbreviated sha
hash is added to distinguish commits with same x, y, and z on different
branches.
If there are uncommited changes, a "+" is appended to the version,
indicating the version is "unclean".
To make it works correctly, a tag "rx.y" have to be created on the last
commit on trunk of x.y release.
-rwxr-xr-x | git-version.sh | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/git-version.sh b/git-version.sh index 0512a26aa..8fe051501 100755 --- a/git-version.sh +++ b/git-version.sh @@ -14,7 +14,6 @@ export LC_ALL=en_US.utf8 export TZ=US/Pacific commit_date=$(git show -s --format=format:"%cd" --date=local) -short_date=$(date --date "$commit_date" "+%Y%m%d") year=$(date --date "$commit_date" "+%Y") month=$(date --date "$commit_date" "+%B") @@ -30,13 +29,16 @@ esac full_date="$month $day$suffix, $year" -sha="g$(git describe --always)" -version="GIT-$short_date-$sha" -versiond="GIT-$short_date-$sha-systemd" +sha="$(git describe --abbrev=1)" +if git describe --all --match trunk > /dev/null 2> /dev/null; then + sha=$(echo "$sha" | sed 's/-g[^-]*$//') +fi +version="$sha" +versiond="$sha-systemd" if [ "$(git diff HEAD | wc -l)" != "0" ]; then - version="$version-MODIFIED" - versiond="$versiond-MODIFIED" + version="$version+" + versiond="$versiond+" fi echo "<!ENTITY version \"$version\">" > version.ent |