This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
GalacticFactory-Legacy/scripts/hooks/post-commit

35 lines
1.1 KiB
Text
Raw Permalink Normal View History

#!/bin/sh
project_root=$(git rev-parse --show-toplevel)
cd "$project_root"/src || exit
echo "post-commit: Checking version numbers"
2024-09-22 11:23:05 -04:00
packwiz_version=$(grep '^version =' pack.toml | awk -F'=' '{print $2}' | tr -d '"' | xargs)
bcc_version=$(grep 'modpackVersion =' config/bcc-common.toml | awk -F'=' '{print $2}' | tr -d '"' | xargs)
echo "post-commit: Packwiz version: $packwiz_version"
echo "post-commit: BCC version: $bcc_version"
if [ "$packwiz_version" != "$bcc_version" ]; then
echo "post-commit: Version numbers do not match, updating config/bcc-common.toml"
sed -i "s/modpackVersion = .*/modpackVersion = \"$packwiz_version\"/" config/bcc-common.toml
else
echo "post-commit: Version numbers match"
fi
2024-03-24 04:34:43 -04:00
echo "post-commit: Refreshing packwiz"
packwiz refresh
2024-03-24 04:34:43 -04:00
echo "post-commit: Adding changes to git"
git add .
echo "post-commit: Checking for changes"
if git diff-index HEAD --; then
echo "post-commit: No changes detected, exiting"
exit 0
fi
2024-03-24 04:34:43 -04:00
echo "post-commit: Amending commit with refreshed files"
git commit --amend --gpg-sign --no-edit --no-verify --reuse-message=HEAD
2024-03-24 04:34:43 -04:00
echo "post-commit: Done"
2024-03-24 04:24:10 -04:00
exit 0