Restore the index after every commit
```git-check-assertions run ./test/git-check-assertions.bats assert_success ```
This commit is contained in:
parent
1ec02587b0
commit
dc74688ce9
1 changed files with 5 additions and 2 deletions
|
|
@ -72,6 +72,9 @@ else
|
|||
echo "No main or master branch found." >&2
|
||||
exit 1
|
||||
fi
|
||||
restore() {
|
||||
git restore -q --staged --worktree .
|
||||
}
|
||||
base="$(git merge-base "$base_branch" HEAD)"
|
||||
mapfile -t commits < <(git rev-list --reverse "${base}..HEAD")
|
||||
|
||||
|
|
@ -92,12 +95,12 @@ for commit_hash in "${commits[@]}"; do
|
|||
printf '%s\n' "$block" | sed 's/^/> /'
|
||||
if ! bash -euo pipefail -c "$block"; then
|
||||
echo "git-check-assertions block failed in $commit_hash" >&2
|
||||
git restore -q .
|
||||
restore
|
||||
echo "Returning to $orig_ref"
|
||||
git checkout -q "$orig_ref"
|
||||
exit 1
|
||||
fi
|
||||
git restore -q .
|
||||
restore
|
||||
fi
|
||||
echo
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue