fix: revert changes on error (#272)
Signed-off-by: knqyf263 <knqyf263@gmail.com>
This commit is contained in:
parent
08331efd39
commit
9d5c9da3de
@ -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
|
||||
@ -21,4 +30,4 @@ if [[ -n $(git status --porcelain) ]]; then
|
||||
git add .
|
||||
git commit -m "${COMMIT_MSG}"
|
||||
git push
|
||||
fi
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user