onos-edit-config
2.02 KB
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
#!/bin/bash
# ----------------------------------------------------
# Used to update the project's refs/meta/config
# ----------------------------------------------------
set -e
GERRIT_USER=${GERRIT_USER:-$USER}
GERRIT_PROJECT=${GERRIT_PROJECT:-onos}
function setup {
DIR=$(mktemp -d /tmp/$GERRIT_PROJECT-config.XXXXX) || { echo "Failed to create temp file"; exit 1; }
cd $DIR
git init
git remote add origin ssh://$GERRIT_USER@gerrit.onosproject.org:29418/$GERRIT_PROJECT
git fetch origin refs/meta/config:refs/remotes/origin/meta/config
git checkout meta/config
}
function cleanup {
# clean up the directory
rm -rf $DIR
}
function testReleaseMembership {
trap "echo 'ERROR: Not a member of the ONOS Release group'; cleanup" ERR
ssh -p 29418 gerrit.onosproject.org gerrit ls-members "ONOS\ Release" | grep -q $GERRIT_USER
}
setup
case $1 in
block)
testReleaseMembership
sed -i '' "s/submit = group/submit = block group/g" project.config
sed -i '' "s/push = block group ONOS Release/push = group ONOS Release/g" project.config
git diff
git commit -am"Blocking submit for all users in project"
git push origin HEAD:refs/meta/config
;;
unblock)
testReleaseMembership
sed -i '' "s/submit = block group/submit = group/g" project.config
sed -i '' "s/push = group ONOS Release/push = block group ONOS Release/g" project.config
git diff
git commit -am"Unblocking submit for all users in project"
git push origin HEAD:refs/meta/config
;;
edit)
echo
echo "Make your changes now."
echo "To push changes, commit them and exit with 0"
echo "To abandon changes, do not commit or exit with non-zero value"
bash -i && git push origin HEAD:refs/meta/config || echo "ABANDONED CHANGES"
;;
*)
echo
echo "USAGE: onos-edit-config <option>"
echo " block: blocks submits for all users in the project"
echo " unblock: unblocks submits for all users in the project"
echo " edit: allows you to make arbitrary changes to project config"
esac
cleanup