Last active
December 18, 2015 11:59
-
-
Save frasertweedale/5780013 to your computer and use it in GitHub Desktop.
git alias to draft/publish to Gerrit, optionally specifying reviewers. Usage: % git <"draft"|"publish"> <target-branch> [reviewer, ...]
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
[alias] | |
gerrit = "!f() { \n\ | |
ACTION=$1 \n\ | |
BRANCH=$2 \n\ | |
shift 2 \n\ | |
RECEIVEPACK=\"\" \n\ | |
for REVIEWER in \"$@\"; do RECEIVEPACK=\"$RECEIVEPACK --reviewer '$REVIEWER'\"; done \n\ | |
if [ -n \"$RECEIVEPACK\" ] \n\ | |
then \n\ | |
git push \"--receive-pack=git receive-pack $RECEIVEPACK\" gerrit HEAD:refs/$ACTION/$BRANCH \n\ | |
else \n\ | |
git push gerrit HEAD:refs/$ACTION/$BRANCH \n\ | |
fi \n\ | |
}; f" | |
draft = "!g() { git gerrit drafts \"$@\"; }; g" | |
publish = "!g() { git gerrit publish \"$@\"; }; g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment