fix(cli): turn of `commit.gpgsign` compatibly with git v1.7.1 (#10679)

Co-authored-by: Marc Cornellà <hello@mcornella.com>
This commit is contained in:
Carlo Sala 2022-03-31 09:27:58 +02:00 committed by GitHub
parent 93435bff49
commit 141d06b602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 6 deletions

View File

@ -573,12 +573,27 @@ function _omz::pr::test {
# Rebase pull request branch against the current master # Rebase pull request branch against the current master
_omz::log info "rebasing PR #$1..." _omz::log info "rebasing PR #$1..."
command git rebase --no-gpg-sign master ohmyzsh/pull-$1 || { local gpgsign
command git rebase --abort &>/dev/null {
_omz::log warn "could not rebase PR #$1 on top of master." # Back up commit.gpgsign setting: use --local to get the current repository
_omz::log warn "you might not see the latest stable changes." # setting, not the global one. If --local is not a known option, it will
_omz::log info "run \`zsh\` to test the changes." # exit with a 129 status code.
return 1 gpgsign=$(command git config --local commit.gpgsign 2>/dev/null)
[[ $? -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null)
command git config commit.gpgsign false
command git rebase master ohmyzsh/pull-$1 || {
command git rebase --abort &>/dev/null
_omz::log warn "could not rebase PR #$1 on top of master."
_omz::log warn "you might not see the latest stable changes."
_omz::log info "run \`zsh\` to test the changes."
return 1
}
} always {
case "$gpgsign" in
"") command git config --unset commit.gpgsign ;;
*) command git config commit.gpgsign "$gpgsign" ;;
esac
} }
_omz::log info "fetch of PR #${1} successful." _omz::log info "fetch of PR #${1} successful."