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
cswimr dea8a7b08a
All checks were successful
Actions / build_export_files (push) Successful in 9s
Actions / autotagger (push) Successful in 13s
Actions / build_docs (push) Successful in 24s
use xargs to trail whitespace
2024-09-22 11:23:05 -04:00

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