diff --git a/pre-push b/pre-push-fediverse similarity index 100% rename from pre-push rename to pre-push-fediverse diff --git a/pre-push-version-increment b/pre-push-version-increment new file mode 100755 index 0000000..fcee1b8 --- /dev/null +++ b/pre-push-version-increment @@ -0,0 +1,42 @@ +#!/bin/bash + +# Path to the version file +VERSION_FILE="src/fenrirscreenreader/fenrirVersion.py" + +# Get current date components +YEAR=$(date +%Y) +MONTH=$(date +%m) +DAY=$(date +%d) + +# Create new version string +NEW_VERSION="$YEAR.$MONTH.$DAY" + +# Get current branch name +BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) + +# Check if file exists +if [ ! -f "$VERSION_FILE" ]; then + echo "Error: Version file not found at $VERSION_FILE" + 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" + +# Check if codeName exists in the file +if grep -q "codeName" "$VERSION_FILE"; then + # Update existing codeName + sed -i "s/codeName = [\"']\{0,1\}[^\"']*[\"']\{0,1\}/codeName = \"$BRANCH_NAME\"/" "$VERSION_FILE" +else + # Add codeName after the version line + sed -i "/version = / a\codeName = \"$BRANCH_NAME\"" "$VERSION_FILE" +fi + +# Add the changed file back to the commit +git add "$VERSION_FILE" + +# 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"