]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tools: improve git-version-next to always output version variables
authorKarel Zak <kzak@redhat.com>
Mon, 22 Sep 2025 13:21:18 +0000 (15:21 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Sep 2025 13:21:18 +0000 (15:21 +0200)
- Always output UL_NEXT_FINAL_RELEASE (previously only for RC releases)
- Add UL_LAST_FINAL_RELEASE for last stable (non-RC) release
- Remove _RAW variables from output for cleaner interface

The UL_NEXT_FINAL_RELEASE now represents the version that will be
released after code stabilization, while UL_LAST_FINAL_RELEASE
represents the last stable release without -rc suffix.

Signed-off-by: Karel Zak <kzak@redhat.com>
tools/git-version-next

index 04ed077a6d905eafec274dcf0cbcf7e22800cc56..9406419404253ffecc667e30ba1b8984960446c4 100755 (executable)
@@ -247,24 +247,30 @@ determine_next_version() {
     esac
 }
 
+# Determine last final (non-RC) release
+if [[ "$UL_LAST_RELEASE" =~ -rc[0-9]+$ ]]; then
+    UL_LAST_FINAL_RELEASE=$(git for-each-ref --sort='-creatordate' \
+        --format='%(tag)' refs/tags \
+        | grep '^v[0-9]' \
+        | grep -v -- '-rc[0-9]*$' \
+        | head -1)
+else
+    UL_LAST_FINAL_RELEASE="$UL_LAST_RELEASE"
+fi
+
 # Determine next version
 UL_NEXT_RELEASE=$(determine_next_version "$UL_LAST_RELEASE" "$RELEASE_TYPE" "$RC_REQUESTED")
 
-# For RC releases, also provide the final release version (without -rc suffix)
-UL_NEXT_FINAL_RELEASE=""
+# Always provide the final release version (after code stabilization)
 if [[ "$UL_NEXT_RELEASE" =~ -rc[0-9]+$ ]]; then
     UL_NEXT_FINAL_RELEASE=$(echo "$UL_NEXT_RELEASE" | sed 's/-rc[0-9]*$//')
+else
+    UL_NEXT_FINAL_RELEASE="$UL_NEXT_RELEASE"
 fi
 
 # Output results
 echo "UL_LAST_RELEASE=$UL_LAST_RELEASE"
-echo "UL_LAST_RELEASE_RAW=$(echo $UL_LAST_RELEASE | sed 's/^v//')"
+echo "UL_LAST_FINAL_RELEASE=$UL_LAST_FINAL_RELEASE"
 echo "UL_LAST_XY_RELEASE=$UL_LAST_XY_RELEASE"
-echo "UL_LAST_XY_RELEASE_RAW=$(echo $UL_LAST_XY_RELEASE | sed 's/^v//')"
 echo "UL_NEXT_RELEASE=$UL_NEXT_RELEASE"
-echo "UL_NEXT_RELEASE_RAW=$(echo $UL_NEXT_RELEASE | sed 's/^v//')"
-
-if [ -n "$UL_NEXT_FINAL_RELEASE" ]; then
-    echo "UL_NEXT_FINAL_RELEASE=$UL_NEXT_FINAL_RELEASE"
-    echo "UL_NEXT_FINAL_RELEASE_RAW=$(echo $UL_NEXT_FINAL_RELEASE | sed 's/^v//')"
-fi
\ No newline at end of file
+echo "UL_NEXT_FINAL_RELEASE=$UL_NEXT_FINAL_RELEASE"
\ No newline at end of file