From 4e75b5bea7312cc718a83f7f7fab4b3430f27496 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Mon, 27 Jun 2022 08:03:28 +0200 Subject: [PATCH] Fixed version script and made generated version unique Signed-off-by: Alexander Borsuk --- tools/unix/version.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/unix/version.sh b/tools/unix/version.sh index 0d7d490649..ff00d48539 100755 --- a/tools/unix/version.sh +++ b/tools/unix/version.sh @@ -4,8 +4,10 @@ set -euo pipefail # Note: other ways to get date use the "when commit was rebased" date. -# This approach counts a number of commits each day based on author's commit date. -COUNT_AND_DATE=( $(git log --date=short --pretty=format:%ad --date=format:'%Y.%m.%d' --since="30 days ago" | sort | uniq -c | tail -1) ) +# This approach counts a number of commits each day based on committer's commit date +# instead of author's commit date, to avoid conflicts when old PRs are merged, but the +# number of today's commits stays the same. +COUNT_AND_DATE=( $(git log --date=short --pretty=format:%cd --date=format:'%Y.%m.%d' --since="30 days ago" | sort | uniq -c | tail -1) ) if [ -z "$COUNT_AND_DATE" ]; then # Fallback: use today's date if there were no commits since last month. COUNT_AND_DATE=( 0 $(date +%Y.%m.%d) )