Skip to content

Instantly share code, notes, and snippets.

@frasertweedale
Last active December 18, 2015 11:59
Show Gist options
  • Save frasertweedale/5780013 to your computer and use it in GitHub Desktop.
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, ...]
[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