My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 51 attachment: gerrit_topic_review_demo.sh (2.4 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh
# Script to try out the gerrit topic review changes described at http://www.kitware.com/source/home/post/62
set -e
set -x

build_gerrit() {
echo Building gerrit with topic review feature
git clone https://github.com/cjh1/gerrit.git -b topic-views-2.2.2-rc1
cd gerrit
mvn package
cd ..
}

install_test_site() {
cat <<__EOF__
Choose the default for everything except the fourth prompt,
authentication method. For that, press ? to see a list,
and choose the last choice, development_become_any_account.
__EOF__
java -jar gerrit/gerrit-war/target/gerrit-2.2-SNAPSHOT.war init -d test_site
}

create_project_remote() {
ssh -v -p 29418 localhost gerrit create-project --name hello
cat <<__EOF__
Alas, there is no way to script setting up access control,
so you will need to use the web interface.

In the access page for the hello project,
add a reference to refs/*, and on that,
Grant Administrator, or maybe Registered User, the
following five permissions:
- Push and Create Reference rights to allow the initial push
- Verify and Code Review rights to allow you to approve changes
- Submit to allow you to commit approved changes
Also, grant +2 on code review so you can approve your own changes.

Finally, in the general page for the hello project,
enable Topic Review.
__EOF__
echo "Press enter when you've done this."
read x
}

create_project_local() {
echo Creating trivial git project
mkdir democlient
cd democlient
mkdir hello
cd hello
git init
# Need the git hooks for commits to be accepted by Gerrit
scp -p -P 29418 localhost:hooks/commit-msg .git/hooks/
cat > hello.c <<_EOF_
#include <stdio.h>

int main(int argc, char **argv)
{
printf("Hello, World!\n");
return 0;
}
_EOF_
git add hello.c
git commit -m "trivial app"
git remote add gerrit ssh://localhost:29418/hello.git
git push gerrit master
cd ..
cd ..
}

create_and_push_topic_branch() {
cd democlient/hello

git checkout -b topic1 master

echo "new file 1" > file1.txt
git add file1.txt
git commit -m "dummy change #1"

echo "new file 2" > file2.txt
git add file2.txt
git commit -m "dummy change #2"

git push gerrit HEAD:refs/for/master/topic1
cd ../..
}

test -d gerrit || build_gerrit
test -d test_site || install_test_site
create_project_remote
create_project_local
create_and_push_topic_branch
Powered by Google Project Hosting