aboutsummaryrefslogtreecommitdiff
path: root/gerrit/gerrit-admin
blob: 4ccd7bd89b543ee40819050afc0d360f4d0e7269 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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

$@