Gerrit » History » Version 12
msuraev, 06/15/2016 11:27 AM
1 | 1 | zecke | h1. Contributing using Gerrit |
---|---|---|---|
2 | |||
3 | 11 | laforge | {{>toc}} |
4 | |||
5 | 10 | laforge | At [[OpenBSC:OsmoDevCon2016]] we discussed problems with our past contribution / patch submission process using mails on the mailing list as well as patchwork. The result is that we want to give Gerrit a try for some time and see if it helps us to have a better process |
6 | 1 | zecke | |
7 | 10 | laforge | Gerrit is a review tool that integrates nicely with git and ssh. You can find general information about Gerrit at https://www.gerritcodereview.com/ |
8 | 1 | zecke | |
9 | 10 | laforge | The advantages of Gerrit are: |
10 | * patch submission status is automatically tracked, also with several revisions for a patch set. |
||
11 | * patches are build-tested (and possibly even further tested) by jenkins before they are applied |
||
12 | * developers + maintainers can formally vote on a patch (developer: -1/0/+1, maintainer: -2/0/+2) |
||
13 | * once a patch has +2 score, it can be (automatically) merged into master |
||
14 | * patch sumissions not via git send-email but direcly from git |
||
15 | |||
16 | h2. Osmocom Subprojects using Gerrit |
||
17 | |||
18 | 1 | zecke | The following projects use Gerrit to contribute changes: |
19 | |||
20 | * libosmocore.git |
||
21 | * libosmo-abis.git |
||
22 | * libosmo-netif.git |
||
23 | * libosmo-sccp.git |
||
24 | * libsmpp34.git |
||
25 | * openbsc.git |
||
26 | * osmo-bts.git |
||
27 | * osmo-iuh.git |
||
28 | * osmo-pcu.git |
||
29 | 5 | zecke | * cellmgr-ng.git |
30 | 1 | zecke | * osmo-sip-connector.git |
31 | |||
32 | h2. Configuring Gerrit/Account |
||
33 | |||
34 | 10 | laforge | You will need to sign-up at https://gerrit.osmocom.org/login/. If you have an Osmocom Redmine account you can use https://osmocom.org/openid as OpenID provider. If you have no Osmocom redmine account, you can simply create one online at the "Register" link in the upper right corner. |
35 | |||
36 | Even without an existing or new redmine account, you should also be able to use any other OpenID provider to authenticate against gerrit (untested). |
||
37 | |||
38 | After the initial sign-up you will need to: |
||
39 | 1 | zecke | |
40 | * Pick a username (can not be changed) |
||
41 | * Add your public ssh key(s) |
||
42 | * Add email addresses you intend to use as author/comitter |
||
43 | |||
44 | h2. Setting up Gerrit for commits and pushing |
||
45 | |||
46 | 2 | zecke | * Add the remote to be able to fetch and push to gerrit |
47 | * Fetch the commit hook that adds Change-Id to each commit to uniquely identify a commit |
||
48 | |||
49 | <pre> |
||
50 | 7 | neels | USERNAME=gerrit_user_name |
51 | PROJECT=$(basename $PWD) |
||
52 | git remote add gerrit ssh://$USERNAME@gerrit.osmocom.org:29418/$PROJECT.git |
||
53 | scp -P 29418 $USERNAME@gerrit.osmocom.org:hooks/commit-msg .git/hooks/ |
||
54 | </pre> |
||
55 | |||
56 | * In case your local username matches the gerrit username, the setup shortens to |
||
57 | |||
58 | <pre> |
||
59 | PROJECT=$(basename $PWD) |
||
60 | git remote add gerrit ssh://gerrit.osmocom.org:29418/$PROJECT.git |
||
61 | scp -P 29418 gerrit.osmocom.org:hooks/commit-msg .git/hooks/ |
||
62 | </pre> |
||
63 | |||
64 | Then |
||
65 | |||
66 | * Push for review |
||
67 | <pre> |
||
68 | git push gerrit HEAD:refs/for/master |
||
69 | </pre> |
||
70 | |||
71 | * Push a user branch |
||
72 | <pre> |
||
73 | 9 | neels | git push gerrit HEAD:refs/heads/users/$USERNAME/topic |
74 | 7 | neels | </pre> |
75 | |||
76 | * Directly push to master if you are allowed to |
||
77 | <pre> |
||
78 | git push gerrit HEAD:refs/heads/master |
||
79 | </pre> |
||
80 | |||
81 | * List changesets in gerrit |
||
82 | <pre> |
||
83 | git ls-remote gerrit changes/* |
||
84 | 2 | zecke | </pre> |
85 | 12 | msuraev | |
86 | h2. Tips and Tricks |
||
87 | |||
88 | If you need to adjust and re-submit patches the easiest way is to create throw-away branch ("R D" in magit-gerrit in emacs for example), make you changes/amendments and than send patch(es) back to gerrit while removing temporary branch automatically with "git review -f". |