From 97bdb341b2a1266c50f03f8d4d35d87382579796 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Sep 2025 21:16:21 +0000 Subject: [PATCH 1/6] Initial plan From 2c387f290765dfa091a21e7993185ec553ec8188 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Sep 2025 21:22:08 +0000 Subject: [PATCH 2/6] feat: add VERSION file update with gitversion semver on checkout Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com> --- VERSION | 1 + src/githooks/_post-checkout.sh | 7 +++++ update-version.sh | 54 ++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 VERSION create mode 100755 update-version.sh diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3602d33 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +5.10.2-1-g97bdb34-dirty diff --git a/src/githooks/_post-checkout.sh b/src/githooks/_post-checkout.sh index cdc43f2..ee3ec44 100755 --- a/src/githooks/_post-checkout.sh +++ b/src/githooks/_post-checkout.sh @@ -21,3 +21,10 @@ if test "$GIT_COMMAND" = "rebase"; then zz_log s "Skip post-checkout hook during rebase." exit 0 fi + +# Update VERSION file with current GitVersion semver +if [ -f "./update-version.sh" ]; then + ./update-version.sh || zz_log w "Failed to update VERSION file" +else + zz_log w "update-version.sh script not found, skipping VERSION file update" +fi diff --git a/update-version.sh b/update-version.sh new file mode 100755 index 0000000..95529c6 --- /dev/null +++ b/update-version.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# Script to update VERSION file with GitVersion semver +# This script handles both GitVersion tool and fallback scenarios + +set -e + +# Define the VERSION file path +VERSION_FILE="VERSION" + +# Function to update VERSION file +update_version_file() { + local version="$1" + if [ -n "$version" ]; then + echo "$version" > "$VERSION_FILE" + echo "Updated VERSION file to: $version" + else + echo "Warning: Could not determine version" + fi +} + +# Function to extract semver from git describe +extract_semver_from_describe() { + local describe_output="$1" + # Extract version from patterns like: + # feature_larasets_5.10.2-1-g97bdb34 -> 5.10.2-1-g97bdb34 + # feature_larasets_5.10.2 -> 5.10.2 + echo "$describe_output" | sed -E 's/^[^_]*_[^_]*_([0-9]+\.[0-9]+\.[0-9]+.*)/\1/' | head -1 +} + +# Try GitVersion first (if available and working) +if command -v dotnet-gitversion >/dev/null 2>&1; then + # Try to get MajorMinorPatch from GitVersion + GITVERSION_OUTPUT=$(dotnet-gitversion -config .gitversion -showvariable MajorMinorPatch 2>/dev/null || echo "") + # Check if output is a valid version number (only digits and dots) + if [ -n "$GITVERSION_OUTPUT" ] && echo "$GITVERSION_OUTPUT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then + update_version_file "$GITVERSION_OUTPUT" + exit 0 + fi +fi + +# Fallback to git describe +GIT_DESCRIBE=$(git describe --tags --always --dirty 2>/dev/null || echo "") +if [ -n "$GIT_DESCRIBE" ]; then + FALLBACK_VERSION=$(extract_semver_from_describe "$GIT_DESCRIBE") + update_version_file "$FALLBACK_VERSION" + exit 0 +fi + +# Final fallback - keep existing version or use default +if [ -f "$VERSION_FILE" ]; then + echo "Warning: Could not determine new version, keeping existing VERSION file" +else + update_version_file "1.0.0" +fi \ No newline at end of file From 51926a7abecfd5cd12163e52318c858468abd23d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Sep 2025 21:24:52 +0000 Subject: [PATCH 3/6] fix: improve version extraction logic for better semver detection Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com> --- VERSION | 2 +- update-version.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 3602d33..2566ef4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.10.2-1-g97bdb34-dirty +5.10.2-2-g2c387f2-dirty diff --git a/update-version.sh b/update-version.sh index 95529c6..b92a380 100755 --- a/update-version.sh +++ b/update-version.sh @@ -31,8 +31,8 @@ extract_semver_from_describe() { if command -v dotnet-gitversion >/dev/null 2>&1; then # Try to get MajorMinorPatch from GitVersion GITVERSION_OUTPUT=$(dotnet-gitversion -config .gitversion -showvariable MajorMinorPatch 2>/dev/null || echo "") - # Check if output is a valid version number (only digits and dots) - if [ -n "$GITVERSION_OUTPUT" ] && echo "$GITVERSION_OUTPUT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then + # Check if output is a valid version number (only digits and dots) and not default + if [ -n "$GITVERSION_OUTPUT" ] && echo "$GITVERSION_OUTPUT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$' && [ "$GITVERSION_OUTPUT" != "1.0.0" ]; then update_version_file "$GITVERSION_OUTPUT" exit 0 fi From b2566d48f29a40a9733fe067bee4cbc36f3aa05f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Sep 2025 21:25:57 +0000 Subject: [PATCH 4/6] feat: add VERSION file update with gitversion semver on checkout Co-authored-by: tomgrv <1809566+tomgrv@users.noreply.github.com> --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2566ef4..8d5126f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.10.2-2-g2c387f2-dirty +5.10.2-3-g51926a7-dirty From e8e0f2815c5a0c422752581a6da74ed2402c5b23 Mon Sep 17 00:00:00 2001 From: "Thomas G." <1809566+tomgrv@users.noreply.github.com> Date: Sat, 20 Sep 2025 22:31:47 +0200 Subject: [PATCH 5/6] feat: support flexible naming Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- update-version.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/update-version.sh b/update-version.sh index b92a380..83270f2 100755 --- a/update-version.sh +++ b/update-version.sh @@ -21,10 +21,12 @@ update_version_file() { # Function to extract semver from git describe extract_semver_from_describe() { local describe_output="$1" - # Extract version from patterns like: + # Extract version from tags ending with a semantic version, e.g.: # feature_larasets_5.10.2-1-g97bdb34 -> 5.10.2-1-g97bdb34 - # feature_larasets_5.10.2 -> 5.10.2 - echo "$describe_output" | sed -E 's/^[^_]*_[^_]*_([0-9]+\.[0-9]+\.[0-9]+.*)/\1/' | head -1 + # release_5.10.2 -> 5.10.2 + # v5.10.2 -> 5.10.2 + # The regex matches any tag ending with X.Y.Z (optionally with suffixes). + echo "$describe_output" | sed -E 's/.*[_v]([0-9]+\.[0-9]+\.[0-9]+([-a-zA-Z0-9\.]*)?)/\1/' | head -1 } # Try GitVersion first (if available and working) From 6f46e7d6cc684a9259aa35fb67f22150204ff88b Mon Sep 17 00:00:00 2001 From: "Thomas G." <1809566+tomgrv@users.noreply.github.com> Date: Sat, 20 Sep 2025 22:32:44 +0200 Subject: [PATCH 6/6] fix: handle legitimate naming Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- update-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update-version.sh b/update-version.sh index 83270f2..7039f6c 100755 --- a/update-version.sh +++ b/update-version.sh @@ -34,7 +34,7 @@ if command -v dotnet-gitversion >/dev/null 2>&1; then # Try to get MajorMinorPatch from GitVersion GITVERSION_OUTPUT=$(dotnet-gitversion -config .gitversion -showvariable MajorMinorPatch 2>/dev/null || echo "") # Check if output is a valid version number (only digits and dots) and not default - if [ -n "$GITVERSION_OUTPUT" ] && echo "$GITVERSION_OUTPUT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$' && [ "$GITVERSION_OUTPUT" != "1.0.0" ]; then + if [ -n "$GITVERSION_OUTPUT" ] && echo "$GITVERSION_OUTPUT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then update_version_file "$GITVERSION_OUTPUT" exit 0 fi