diff options
Diffstat (limited to 'gerrit/gerrit-admin')
-rwxr-xr-x | gerrit/gerrit-admin | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/gerrit/gerrit-admin b/gerrit/gerrit-admin new file mode 100755 index 0000000..4ccd7bd --- /dev/null +++ b/gerrit/gerrit-admin @@ -0,0 +1,67 @@ +#!/bin/bash +# Simple script to automate gerrit tasks. +# +# Note: you may need to configure proper username to use +# in your ~/.ssh/config, e.g.: +# +# Host review.linaro.org +# user first.last + +PORT=-p29418 + +function list_projs() { + # List projects matching grep extended pattern (i.e. normal regexp) + for repository in `ssh $PORT $GERRIT_URL gerrit ls-projects | grep -E $1`; do + echo $repository + done +} + +function set_parent() { + # Sets the new parent of the project. + # $1: the parent to set + # $2: the project whose parent has to be changed + ssh $PORT $GERRIT_URL gerrit set-project-parent --parent $1 $2 +} + +function set_people_parent() { + # Sets the parent repository for all people/ ones as the people.git project + # a container for permissions on those repositories. + for repository in `ssh $PORT $GERRIT_URL gerrit ls-projects | grep people\/ `; do + set_parent 'people' $repository + done +} + +function set_projs_parent() { + # Sets the parent repository for all projects matching regex pattern + # If in doubt, run list_projs with the same regex first! + for repository in `ssh $PORT $GERRIT_URL gerrit ls-projects | grep -E $1`; do + set_parent "$2" $repository + echo $repository + done +} + +function set_submit_type() { + # Sets the "submit type" for all projects matching regex pattern + # If in doubt, run list_projs with the same regex first! + if [ $# -ne 2 ]; then + echo "Usage: $0 set_submit_type <project_regex> <submit_type>" + echo "For possible submit types, see gerrit's help:" + echo " ssh $PORT $GERRIT_URL gerrit set-project -h" + exit 1 + fi + for repository in `ssh $PORT $GERRIT_URL gerrit ls-projects | grep -E $1`; do + ssh $PORT $GERRIT_URL gerrit set-project $repository --submit-type $2 + echo $repository + done +} + +GERRIT_URL=$1 +shift + +if [ -z "$GERRIT_URL" -o $# -eq 0 ]; then + echo "Usage: $0 <user@gerrit.host> <command> ..." + echo "For available commands, browse the source of this script" + exit +fi + +$@ |