37 lines
1.1 KiB
Text
Executable file
37 lines
1.1 KiB
Text
Executable file
#!/usr/bin/env nix-shell
|
|
#! nix-shell -i bash ../shell.nix
|
|
|
|
# Get the target branch (the branch being merged into)
|
|
target_branch=""
|
|
|
|
# Check if we're in the middle of a merge
|
|
if [ -f .git/MERGE_HEAD ]; then
|
|
# We're in a merge, check if the current branch is main
|
|
current_branch=$(git branch --show-current)
|
|
if [ "$current_branch" = "main" ]; then
|
|
target_branch="main"
|
|
fi
|
|
fi
|
|
|
|
# If we're merging into main, run nix flake check
|
|
if [ "$target_branch" = "main" ]; then
|
|
echo "Merging into main branch - running nix flake check..."
|
|
|
|
echo "stashing all uncommitted changes with named stash (excluding hooks)"
|
|
git stash push -q --keep-index -m "pre-merge-stash-$(date +%s)" -- ':!.hooks/'
|
|
|
|
echo "checking flakes all compile"
|
|
nix flake check
|
|
|
|
if [ ! $? -eq 0 ]; then
|
|
echo "Error: nix flake check failed. Merge aborted."
|
|
echo "Please fix the issues and try merging again."
|
|
exit 1
|
|
fi
|
|
|
|
echo "nix flake check passed. Merge can proceed."
|
|
else
|
|
echo "Not merging into main branch, skipping nix flake check."
|
|
fi
|
|
|
|
exit 0
|