blob: 554ad3594ce6ebe7c18978ccf4ff3f89c15378ad [file] [log] [blame]
Brian O'Connor3fad9bc2016-03-01 17:39:09 -08001#!/bin/bash
2
3GERRIT_USER=${GERRIT_USER:-$USER}
4GERRIT_PROJECT=${GERRIT_PROJECT:-onos}
5
6function setup() {
7 DIR=$(mktemp -d /tmp/$GERRIT_PROJECT-config.XXXXX) || { echo "Failed to create temp file"; exit 1; }
8 cd $DIR
9 git init
10 git remote add origin ssh://$GERRIT_USER@gerrit.onosproject.org:29418/$GERRIT_PROJECT
11 git fetch origin refs/meta/config:refs/remotes/origin/meta/config
12 git checkout meta/config
13}
14
15function cleanup() {
16 # clean up the directory
17 rm -rf $OUT
18}
19
20setup
21case $1 in
22 block)
23 sed -i '' "s/submit = group/submit = block group/g" project.config
24 git diff
25 git commit -am"Blocking submit for all users in project"
26 git push origin HEAD:refs/meta/config
27 ;;
28 unblock)
29 echo unblock
30 sed -i '' "s/submit = block group/submit = group/g" project.config
31 git diff
32 git commit -am"Unblocking submit for all users in project"
33 git push origin HEAD:refs/meta/config
34 ;;
35 edit)
36 echo
37 echo "Make your changes now."
38 echo "To push changes, commit them and exit with 0"
39 echo "To abandon changes, do not commit or exit with non-zero value"
40 bash -i && git push origin HEAD:refs/meta/config || echo "ABANDONED CHANGES"
41 ;;
42 *)
43 echo
44 echo "USAGE: onos-edit-config <option>"
45 echo " block: blocks submits for all users in the project"
46 echo " unblock: unblocks submits for all users in the project"
47 echo " edit: allows you to make arbitrary changes to project config"
48esac
49cleanup