From 1b5c9e71c96a8711b9b254a2025a19d2b5601ab0 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 1 Jan 2024 02:49:21 +0100 Subject: Fixed weird edge case in day revision part --- version | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'version') diff --git a/version b/version index b967060..e7c6cb3 100755 --- a/version +++ b/version @@ -15,13 +15,15 @@ try_tag() { 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}" + if git diff-index --quiet HEAD --; then + latest="$(git rev-list -1 --date=format:${fmt} --pretty=%ad --no-commit-header HEAD)" + modified=0 else - version="$(date +${fmt}).1" + latest="$(date +${fmt})" + modified=1 fi + count=$(git rev-list --date=format:${fmt} --pretty=%ad --no-commit-header HEAD | sed -n /${latest}/p | wc -l) + count=$(( ${count} + ${modified} )) + version="${latest}.${count}" fi echo "${version}" -- cgit v1.1