34 lines
1.1 KiB
Bash
Executable file
34 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
project_root=$(git rev-parse --show-toplevel)
|
|
cd "$project_root"/src || exit
|
|
|
|
echo "post-commit: Checking version numbers"
|
|
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
|
|
|
|
echo "post-commit: Refreshing packwiz"
|
|
packwiz refresh
|
|
|
|
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
|
|
|
|
echo "post-commit: Amending commit with refreshed files"
|
|
git commit --amend --gpg-sign --no-edit --no-verify --reuse-message=HEAD
|
|
|
|
echo "post-commit: Done"
|
|
exit 0
|