fix(cli): turn of `commit.gpgsign` compatibly with git v1.7.1 (#10679)
Co-authored-by: Marc Cornellà <hello@mcornella.com>
Diff
1diff --git a/lib/cli.zsh b/lib/cli.zsh
2index c2fba8556e499e969e821c1d3ac9979d6ffe1369..bf783d9f34cc5200890865384a44502520774bf3 100644
3--- a/lib/cli.zsh
4+++ b/lib/cli.zsh
5@@ -573,12 +573,27 @@ function _omz::pr::test {
6 7 # Rebase pull request branch against the current master
8 _omz::log info "rebasing PR #$1..."
9- command git rebase --no-gpg-sign master ohmyzsh/pull-$1 || {
10- command git rebase --abort &>/dev/null
11- _omz::log warn "could not rebase PR #$1 on top of master."
12- _omz::log warn "you might not see the latest stable changes."
13- _omz::log info "run \`zsh\` to test the changes."
14- return 1
15+ local gpgsign
16+ {
17+ # Back up commit.gpgsign setting: use --local to get the current repository
18+ # setting, not the global one. If --local is not a known option, it will
19+ # exit with a 129 status code.
20+ gpgsign=$(command git config --local commit.gpgsign 2>/dev/null)
21+ [[ $? -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null)
22+ command git config commit.gpgsign false
23+
24+ command git rebase master ohmyzsh/pull-$1 || {
25+ command git rebase --abort &>/dev/null
26+ _omz::log warn "could not rebase PR #$1 on top of master."
27+ _omz::log warn "you might not see the latest stable changes."
28+ _omz::log info "run \`zsh\` to test the changes."
29+ return 1
30+ }
31+ } always {
32+ case "$gpgsign" in
33+ "") command git config --unset commit.gpgsign ;;
34+ *) command git config commit.gpgsign "$gpgsign" ;;
35+ esac
36 }
3738 _omz::log info "fetch of PR #${1} successful."