blob: b9670604d1a3c76084bd54f295c953259b431c4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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}"
|