fix: fixed pre and post commit hook behavior

This commit is contained in:
Leyla Becker 2025-10-20 20:55:35 -05:00
parent 290c0692bb
commit f21777b1fb
4 changed files with 48 additions and 16 deletions

View file

@ -4,14 +4,28 @@
# Get current branch name
current_branch=$(git branch --show-current)
# Only restore stash if we're on main branch and a merge just completed
# Only perform actions if we're on main branch and a merge just completed
if [ "$current_branch" = "main" ]; then
# Check if there are any stashes to restore
if git stash list | grep -q "stash@"; then
echo "Post-merge: restoring stashed changes on main branch"
git stash pop -q
echo "Post-merge on main branch - running nix flake check"
# Run nix flake check after merge into main
nix flake check
if [ ! $? -eq 0 ]; then
echo "Warning: nix flake check failed after merge into main"
echo "Please fix the issues as soon as possible"
else
echo "Post-merge: no stash to restore on main branch"
echo "nix flake check passed after merge"
fi
# Check if there are any pre-commit stashes to restore
recent_stash=$(git stash list | grep "pre-commit-stash-" | head -n 1 | cut -d: -f1)
if [ -n "$recent_stash" ]; then
echo "Post-merge: restoring pre-commit stash on main branch"
git stash pop -q "$recent_stash"
else
echo "Post-merge: no pre-commit stash to restore on main branch"
fi
else
echo "Post-merge: no action needed on branch '$current_branch'"