Brian O'Connor | 3fad9bc | 2016-03-01 17:39:09 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame^] | 2 | # ---------------------------------------------------- |
| 3 | # Used to update the project's refs/meta/config |
| 4 | # ---------------------------------------------------- |
| 5 | |
| 6 | set -e |
Brian O'Connor | 3fad9bc | 2016-03-01 17:39:09 -0800 | [diff] [blame] | 7 | |
| 8 | GERRIT_USER=${GERRIT_USER:-$USER} |
| 9 | GERRIT_PROJECT=${GERRIT_PROJECT:-onos} |
| 10 | |
| 11 | function 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 | |
| 20 | function cleanup() { |
| 21 | # clean up the directory |
| 22 | rm -rf $OUT |
| 23 | } |
| 24 | |
| 25 | setup |
| 26 | case $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" |
| 53 | esac |
| 54 | cleanup |