From 13845d5098a831c59a5f26091171d22b64941779 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Sun, 21 Nov 2021 15:58:55 +0000 Subject: [PATCH] fix(shell): git recommit command When running git commit it was supposed to update the commit message you are currently working on. When running commit with git hooks setup the commit may fail due to a invalid message. This now splits out the command so you can run `grc` (git recommit) to reedit the commit message that failed rather then having to enter the message again in a new commit message. --- site-modules/core/files/oh-my-zsh/custom/git.zsh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/site-modules/core/files/oh-my-zsh/custom/git.zsh b/site-modules/core/files/oh-my-zsh/custom/git.zsh index dd5206d..b1253fe 100644 --- a/site-modules/core/files/oh-my-zsh/custom/git.zsh +++ b/site-modules/core/files/oh-my-zsh/custom/git.zsh @@ -22,10 +22,13 @@ function ggpushpr() { fi } -function gc() { - if [[ -f "$(git rev-parse --show-toplevel)/.git/COMMIT_EDITMSG" ]]; then - git commit -t "$(git rev-parse --show-toplevel)/.git/COMMIT_EDITMSG" - else - git commit -v +function grc() { + cat "$(git rev-parse --show-toplevel)/.git/COMMIT_EDITMSG" \ + | grep -B 99999999 '# ------------------------ >8 ------------------------' \ + > "$(git rev-parse --show-toplevel)/.git/COMMIT_TEMPLATE" + + git commit -t "$(git rev-parse --show-toplevel)/.git/COMMIT_TEMPLATE" +} + fi }