diff options
author | Aki <please@ignore.pl> | 2023-12-28 15:34:37 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-12-28 16:08:17 +0100 |
commit | 8eecae65bb077d6e89935066ec5d4fbb060168cc (patch) | |
tree | 6ea82e3d0e8b66c2a344bbfe530a18921041c0c5 /version | |
parent | a690ee5ab819ef03176194b044a6854b2a07e1ab (diff) | |
download | mirror-8eecae65bb077d6e89935066ec5d4fbb060168cc.zip mirror-8eecae65bb077d6e89935066ec5d4fbb060168cc.tar.gz mirror-8eecae65bb077d6e89935066ec5d4fbb060168cc.tar.bz2 |
Last version component is now generated fully automatically
Diffstat (limited to 'version')
-rwxr-xr-x | version | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -0,0 +1,27 @@ +#!/bin/sh +# TODO: Think of a way to generate version without git repository for source tarballs. Making the script overwrite +# itself with a static version sounds good enough, really. +try_tag() { + local tag + if tag=$(git describe --exact-match --tags --dirty=-dirty 2>/dev/null); then + case "${tag}" in + *-dirty) return 1;; + *) echo "${tag}"; return 0;; + esac + fi + return 1 +} + + +if ! version=$(try_tag); then + fmt=%Y%m%d + set -- $(git rev-list --date=format:${fmt} --pretty=%ad --no-commit-header --since=yesterday HEAD) + if [ $# -gt 0 ]; then + suffix=$# + git diff-index --quiet HEAD -- || suffix=$(( $# + 1 )) + version="$1.${suffix}" + else + version="$(date +${fmt}).1" + fi +fi +echo "${version}" |