fix: revert changes on error (#272)

Signed-off-by: knqyf263 <knqyf263@gmail.com>
This commit is contained in:
Teppei Fukuda 2024-02-23 19:59:36 +04:00 committed by GitHub
parent 08331efd39
commit 9d5c9da3de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,13 @@
#!/bin/bash -eu
#!/bin/bash -eEu
HEAD=$(git rev-parse HEAD)
shopt -s inherit_errexit
on_error() {
echo "[Err] Revert changes" >&2
git reset --hard "${HEAD}"
exit 1
}
trap on_error ERR
TARGET=$1
COMMIT_MSG=$2