From 1f837964dad1b13290d98adc134c256417340700 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 6 Dec 2024 14:19:48 -0500 Subject: [PATCH] Fixed a few things with version increment. --- pre-push-version-increment | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pre-push-version-increment b/pre-push-version-increment index fcee1b8..efc8ef1 100755 --- a/pre-push-version-increment +++ b/pre-push-version-increment @@ -1,7 +1,7 @@ #!/bin/bash # Path to the version file -VERSION_FILE="src/fenrirscreenreader/fenrirVersion.py" +versionFile="src/fenrirscreenreader/fenrirVersion.py" # Get current date components YEAR=$(date +%Y) @@ -9,34 +9,34 @@ MONTH=$(date +%m) DAY=$(date +%d) # Create new version string -NEW_VERSION="$YEAR.$MONTH.$DAY" +newVersion="$YEAR.$MONTH.$DAY" # Get current branch name -BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) +branchName=$(git rev-parse --abbrev-ref HEAD) # Check if file exists -if [ ! -f "$VERSION_FILE" ]; then - echo "Error: Version file not found at $VERSION_FILE" +if [ ! -f "$versionFile" ]; then + echo "Error: Version file not found at $versionFile" exit 1 fi # Update the version in the file # This handles different possible formats of the version line -sed -i "s/version = [\"']\{0,1\}[0-9.]\+[\"']\{0,1\}/version = \"$NEW_VERSION\"/" "$VERSION_FILE" +sed -i "s/version = [\"']\{0,1\}[0-9.]\+[\"']\{0,1\}/version = \"$newVersion\"/" "$versionFile" # Check if codeName exists in the file -if grep -q "codeName" "$VERSION_FILE"; then +if grep -q "codeName" "$versionFile"; then # Update existing codeName - sed -i "s/codeName = [\"']\{0,1\}[^\"']*[\"']\{0,1\}/codeName = \"$BRANCH_NAME\"/" "$VERSION_FILE" + sed -i "s/codeName = [\"']\{0,1\}[^\"']*[\"']\{0,1\}/codeName = \"$branchName\"/" "$versionFile" else # Add codeName after the version line - sed -i "/version = / a\codeName = \"$BRANCH_NAME\"" "$VERSION_FILE" + sed -i "/version = / a\codeName = \"$branchName\"" "$versionFile" fi # Add the changed file back to the commit -git add "$VERSION_FILE" +git add "$versionFile" # Amend the last commit to include the version update # Use the original commit message -COMMIT_MSG=$(git log -1 --pretty=%B) -git commit --amend -m "$COMMIT_MSG" +commitMessage=$(git log -1 --pretty=%B) +git commit --amend -m "$commitMessage"