Last active
December 6, 2018 07:58
-
-
Save sembozdemir/85663f9d451cd43e2759a72a6a8b1006 to your computer and use it in GitHub Desktop.
Gerrit push aliases for ZSH
This file contains hidden or 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
# 1- Enable git plugin -> plugins=( git ) | |
# 2- Add these lines in your .zshrc file | |
# 3- Edit your reviewers in gerrit_reviewers() function below | |
# 4- Run `gpr <branch_name>` to push, `gpr! <branch_name>` to push as Draft | |
# Aliases For gerrit | |
function gerrit_reviewers() { | |
echo "%[email protected],[email protected],[email protected]" | |
} | |
gpr() { | |
local reviewers=$(gerrit_reviewers) | |
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then | |
git push origin "HEAD:refs/for/${*}${reviewers}" | |
else | |
[[ "$#" == 0 ]] && local b="$(git_current_branch)" | |
git push origin "HEAD:refs/for/${b:=$1}${reviewers}" | |
fi | |
} | |
compdef _git gpr=git-checkout | |
gpr!() { | |
local reviewers=$(gerrit_reviewers) | |
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then | |
git push origin "HEAD:refs/drafts/${*}${reviewers}" | |
else | |
[[ "$#" == 0 ]] && local b="$(git_current_branch)" | |
git push origin "HEAD:refs/drafts/${b:=$1}${reviewers}" | |
fi | |
} | |
compdef _git gpr!=git-checkout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment