Last active
August 3, 2017 10:21
-
-
Save spudfkc/7345308 to your computer and use it in GitHub Desktop.
Uses Gerrit's REST API to add a reviewer to a change
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
| #!/bin/bash | |
| USERNAME="<HTTP-USERNAME>" | |
| PASSWORD="<HTTP-PASSWORD>" | |
| BASE_URL="<GERRIT-URL>" | |
| REVIEWER="<DEFAULT-REVIEWER-EMAIL>" | |
| CURL=$(which curl) | |
| if [ -z "$CURL" ] | |
| then | |
| echo "could not find curl" | |
| exit 1 | |
| fi | |
| #parse args | |
| if [ -z "$1" ] | |
| then | |
| echo "Usage: gerrit-add-reviewer CHANGEID [REVIEWEREMAIL]" | |
| exit 1 | |
| fi | |
| CHANGE="$1/reviewers" | |
| URL="$BASE_URL/a/changes/$CHANGE" | |
| if [ ! -z "$2" ] | |
| then | |
| REVIEWER="$2" | |
| fi | |
| HEADER="'Content-Type: application/json'" | |
| JSON="'{\"reviewer\": \"$REVIEWER\"}'" | |
| CMD="$CURL -s -k --digest -u $USERNAME:$PASSWORD -X POST -H $HEADER -d $JSON $URL" | |
| eval $CMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment