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