Last active
October 14, 2023 07:16
-
-
Save azu/824c4f96a6eabababb7bd4034dc053d5 to your computer and use it in GitHub Desktop.
Gitメモ: メモをコミットして作業ツリー自体はメモを書く直前に戻すcommit -hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 📝 [Note] Mode -- if commit message starts with "📝" or includes "[Note]" | |
IS_NOTE_MODE=$(git log -1 --pretty=%B | grep -E '^(📝|\[Note\])') | |
if [[ -n "${IS_NOTE_MODE}" ]]; then | |
# メモの作業内容を戻すコミットをする | |
headSHA=$(git rev-parse HEAD) | |
git revert --no-commit HEAD | |
git ls-tree -r --name-only HEAD | xargs git commit -m "↩️ ${headSHA}" -- | |
# メモを書く直前の状態に作業内容を戻す | |
git revert --no-commit HEAD | |
# terminal notification | |
# remove 📝 and [Note] | |
trimCommitMesasge=$(echo "${GIT_COMMIT_MSG}" | sed -e 's/📝//' -e 's/\[Note\]//') | |
osascript -e "display notification \"${trimCommitMesasge}\" with title \"📝 メモを記録\"" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment