Marian Harbach | ebeb154 | 2019-12-13 10:42:46 +0100 | [diff] [blame] | 1 | :linkattrs: |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 2 | = Project Owner Guide |
| 3 | |
| 4 | This is a Gerrit guide that is dedicated to project owners. It |
| 5 | explains the many possibilities that Gerrit provides to customize the |
| 6 | workflows for a project. |
| 7 | |
| 8 | [[project-owner]] |
| 9 | == What is a project owner? |
| 10 | |
| 11 | Being project owner means that you own a project in Gerrit. |
| 12 | Technically this is expressed by having the |
| 13 | link:access-control.html#category_owner[Owner] access right on |
Jonathan Nieder | 5758f18 | 2015-03-30 11:28:55 -0700 | [diff] [blame] | 14 | `+refs/*+` on that project. As project owner you have the permission to |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 15 | edit the access control list and the project settings of the project. |
| 16 | It also means that you should get familiar with these settings so that |
| 17 | you can adapt them to the needs of your project. |
| 18 | |
| 19 | Being project owner means being responsible for the administration of |
| 20 | a project. This requires having a deeper knowledge of Gerrit than the |
| 21 | average user. Normally per team there should be 2 to 3 persons, who |
| 22 | have a certain level of Git/Gerrit knowledge, assigned as project |
| 23 | owners. It normally doesn't make sense that everyone in a team is |
| 24 | project owner. For normal team members it is sufficient to be committer |
| 25 | or contributor. |
| 26 | |
| 27 | [[access-rights]] |
| 28 | == Access Rights |
| 29 | |
| 30 | As a project owner you can edit the access control list of your |
| 31 | project. This allows you to grant permissions on the project to |
| 32 | different groups. |
| 33 | |
| 34 | Gerrit comes with a rich set of permissions which allow a very |
| 35 | fine-grained control over who can do what on a project. Access |
| 36 | control is one of the most powerful Gerrit features but it is also a |
| 37 | rather complex topic. This guide will only highlight the most |
| 38 | important aspects of access control, but the link:access-control.html[ |
| 39 | Access Control] chapter explains all the details. |
| 40 | |
| 41 | [[edit-access-rights]] |
| 42 | === Editing Access Rights |
| 43 | |
| 44 | To see the access rights of your project |
| 45 | |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 46 | - go to the Gerrit Web UI |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 47 | - click on the `Projects` > `List` menu entry |
| 48 | - find your project in the project list and click on it |
| 49 | - click on the `Access` menu entry |
| 50 | |
| 51 | By clicking on the `Edit` button the access rights become editable and |
| 52 | you may save any changes by clicking on the `Save Changes` button. |
| 53 | Optionally you can provide a `Commit Message` to explain the reasons |
| 54 | for changing the access rights. |
| 55 | |
| 56 | The access rights are stored in the project's Git repository in a |
| 57 | special branch called `refs/meta/config`. On this branch there is a |
| 58 | `project.config` file which contains the access rights. More |
| 59 | information about this storage format can be found in the |
| 60 | link:config-project-config.html[Project Configuration File Format] |
| 61 | chapter. What is important to know is that by looking at the history |
| 62 | of the `project.config` file on the `refs/meta/config` branch you can |
| 63 | always see how the access rights were changed and by whom. If a good |
| 64 | commit message is provided you can also see from the history why the |
| 65 | access rights were modified. |
| 66 | |
Dave Borowitz | a3d6788 | 2015-06-05 15:22:23 -0700 | [diff] [blame] | 67 | If a Git browser such as gitweb is configured for the Gerrit server you |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 68 | can find a link to the history of the `project.config` file in the |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 69 | Web UI. Otherwise you may inspect the history locally. If you have |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 70 | cloned the repository you can do this by executing the following |
| 71 | commands: |
| 72 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 73 | ---- |
Edwin Kempin | 32f314b | 2016-10-12 20:05:27 +0200 | [diff] [blame] | 74 | $ git fetch ssh://localhost:29418/project refs/meta/config |
| 75 | $ git checkout FETCH_HEAD |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 76 | $ git log project.config |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 77 | ---- |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 78 | |
| 79 | Non project owners may still edit the access rights and propose the |
| 80 | modifications to the project owners by clicking on the `Save for |
| 81 | Review` button. This creates a new change with the access rights |
| 82 | modifications that can be approved by a project owner. The project |
| 83 | owners are automatically added as reviewer on this change so that they |
| 84 | get informed about it by email. |
| 85 | |
| 86 | [[inheritance]] |
| 87 | === Inheritance |
| 88 | |
| 89 | Normally when a new project is created in Gerrit it already has some |
| 90 | access rights which are inherited from the parent projects. |
| 91 | Projects in Gerrit are organized hierarchically as a tree with the |
David Shevitz | 7f9b34d | 2018-03-19 13:24:57 -0700 | [diff] [blame] | 92 | `All-Projects` project as root from which all projects inherit. Each |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 93 | project can have only a single parent project, multi-inheritance is |
| 94 | not supported. |
| 95 | |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 96 | Looking at the access rights of your project in the Gerrit Web UI, you |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 97 | only see the access rights which are defined on that project. To see |
| 98 | the inherited access rights you must follow the link to the parent |
| 99 | project under `Rights Inherit From`. |
| 100 | |
| 101 | Inherited access rights can be overwritten unless they are defined as |
| 102 | link:access-control.html#block[BLOCK rule]. BLOCK rules are used to |
| 103 | limit the possibilities of the project owners on the inheriting |
| 104 | projects. With this, global policies can be enforced on all projects. |
| 105 | Please note that Gerrit doesn't prevent you from assigning access |
| 106 | rights that contradict an inherited BLOCK rule, but these access rights |
| 107 | will simply have no effect. |
| 108 | |
| 109 | If you are responsible for several projects which require the same |
| 110 | permissions, it makes sense to have a common parent for them and to |
| 111 | maintain the access rights on that common parent. Changing the parent |
| 112 | of a project is only allowed for Gerrit administrators. This means you |
| 113 | need to contact the administrator of your Gerrit server if you want to |
| 114 | reparent your project. One way to do this is to change the parent |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 115 | project in the Web UI, save the modifications for review and get the |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 116 | change approved and merged by a Gerrit administrator. |
| 117 | |
| 118 | [[refs]] |
| 119 | === References |
| 120 | |
| 121 | Access rights in Gerrit are assigned on references (aka refs). Refs in |
| 122 | Git exist in different namespaces, e.g. all branches normally exist |
| 123 | under `refs/heads/` and all tags under `refs/tags/`. In addition there |
| 124 | are a number of link:access-control.html#references_special[special refs] |
| 125 | and link:access-control.html#references_magic[magic refs]. |
| 126 | |
Patrick Hiesel | a9c11a7 | 2019-01-16 08:38:19 +0100 | [diff] [blame] | 127 | Gerrit only supports tags that are reachable by any ref not owned by |
James Muir | 3ed66d6 | 2023-07-05 08:51:57 -0400 | [diff] [blame] | 128 | Gerrit. This includes branches (refs/heads/\*) or custom ref namespaces |
Patrick Hiesel | a9c11a7 | 2019-01-16 08:38:19 +0100 | [diff] [blame] | 129 | (refs/my-company/*). Tagging a change ref is not supported. |
| 130 | When filtering tags by visibility, Gerrit performs a reachability check |
| 131 | and will present the user ony with tags that are reachable by any ref |
| 132 | they can see. |
| 133 | |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 134 | Access rights can be assigned on a concrete ref, e.g. |
| 135 | `refs/heads/master` but also on ref patterns and regular expressions |
| 136 | for ref names. |
| 137 | |
Jonathan Nieder | 5758f18 | 2015-03-30 11:28:55 -0700 | [diff] [blame] | 138 | A ref pattern ends with `+/*+` and describes a complete ref name |
| 139 | namespace, e.g. access rights assigned on `+refs/heads/*+` apply to all |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 140 | branches. |
| 141 | |
| 142 | Regular expressions must start with `^`, e.g. access rights assigned |
Jonathan Nieder | 5758f18 | 2015-03-30 11:28:55 -0700 | [diff] [blame] | 143 | on `+^refs/heads/rel-.*+` would apply to all `+rel-*+` branches. |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 144 | |
| 145 | [[groups]] |
| 146 | === Groups |
| 147 | |
| 148 | Access rights are granted to groups. It is useful to know that Gerrit |
| 149 | maintains its own groups internally but also supports different external |
| 150 | group backends. |
| 151 | |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 152 | The Gerrit internal groups can be seen in the Gerrit Web UI by clicking |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 153 | on the `Groups` > `List` menu entry. By clicking on a group you can |
| 154 | edit the group members (`Members` tab) and the group options |
| 155 | (`General` tab). |
| 156 | |
| 157 | Gerrit internal groups contain users as members, but can also include |
| 158 | other groups, even external groups. |
| 159 | |
| 160 | Every group is owned by an owner group. Only members of the owner |
| 161 | group can administrate the owned group (assign members, edit the group |
| 162 | options). A group can own itself; in this case members of the group |
| 163 | can, for example, add further members to the group. When you create new |
| 164 | groups for your project to assign access rights to committer or other |
| 165 | roles, make sure that they are owned by the project owner group. |
| 166 | |
| 167 | An important setting on a group is the option |
| 168 | `Make group visible to all registered users.`, which defines whether |
| 169 | non-members can see who is member of the group. |
| 170 | |
| 171 | New internal Gerrit groups can be created under `Groups` > |
| 172 | `Create New Group`. This menu is only available if you have the global |
| 173 | capability link:access-control.html#capability_createGroup[Create Group] |
| 174 | assigned. |
| 175 | |
| 176 | Gerrit also has a set of special |
| 177 | link:access-control.html#system_groups[system groups] that you might |
| 178 | find useful. |
| 179 | |
| 180 | External groups need to be prefixed when assigning access rights to |
| 181 | them, e.g. link:access-control.html#ldap_groups[LDAP group names] need |
| 182 | to be prefixed with `ldap/`. |
| 183 | |
David Pursehouse | 122f078 | 2018-09-28 13:45:23 +0900 | [diff] [blame] | 184 | If the link:https://gerrit-review.googlesource.com/admin/repos/plugins/singleusergroup[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 185 | singleusergroup,role=external,window=_blank] plugin is installed you can also directly assign |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 186 | access rights to users, by prefixing the username with `user/` or the |
| 187 | user's account ID by `userid/`. |
| 188 | |
| 189 | [[common-access-rights]] |
| 190 | === Common Access Rights |
| 191 | |
| 192 | Different roles in a project, such as developer (committer) or |
| 193 | contributor, need different access rights. Examples for which access |
| 194 | rights are typically assigned for which role are described in the |
| 195 | link:access-control.html#example_roles[Access Control] chapter. |
| 196 | |
| 197 | [[code-review]] |
| 198 | === Code Review |
| 199 | |
| 200 | Gerrit's main functionality is code review, however using code review |
| 201 | is optional and you may decide to only use Gerrit as a Git server with |
| 202 | access control. Whether you allow only pushes for review or also |
| 203 | direct pushes depends on the project's access rights. |
| 204 | |
| 205 | To push a commit for review it must be pushed to |
| 206 | link:access-control.html#refs_for[refs/for/<branch-name>]. This means |
| 207 | the link:access-control.html#category_push_review[Push] access right |
| 208 | must be assigned on `refs/for/<branch-name>`. |
| 209 | |
| 210 | To allow direct pushes and bypass code review, the |
| 211 | link:access-control.html#category_push_direct[Push] access right is |
| 212 | required on `refs/heads/<branch-name>`. |
| 213 | |
| 214 | By pushing for review you are not only enabling the review workflow, |
Edwin Kempin | cee50e7 | 2014-04-24 09:40:22 +0200 | [diff] [blame] | 215 | but you can also get link:#continuous-integration[automatic |
| 216 | verifications from a build server] before changes are merged. In |
| 217 | addition you can benefit from Gerrit's merge strategies that can |
| 218 | automatically merge/rebase commits on server side if necessary. You can |
| 219 | control the merge strategy by configuring the |
Changcheng Xiao | 2188598 | 2019-01-15 18:16:51 +0100 | [diff] [blame] | 220 | link:config-project-config.html#submit-type[submit type] on the project. If you |
Edwin Kempin | cee50e7 | 2014-04-24 09:40:22 +0200 | [diff] [blame] | 221 | bypass code review you always need to merge/rebase manually if the tip |
| 222 | of the destination branch has moved. Please keep this in mind if you |
| 223 | choose to not work with code review because you think it's easier to |
| 224 | avoid the additional complexity of the review workflow; it might |
| 225 | actually not be easier. |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 226 | |
| 227 | You may also enable link:user-upload.html#auto_merge[auto-merge on |
| 228 | push] to benefit from the automatic merge/rebase on server side while |
| 229 | pushing directly into the repository. |
| 230 | |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 231 | [[project-options]] |
| 232 | == Project Options |
| 233 | |
| 234 | As project owner you can control several options on your project. |
| 235 | The different options are described in the |
Stefan Lay | 08ba473 | 2014-05-05 16:36:12 +0200 | [diff] [blame] | 236 | link:project-configuration.html#project_options[Project Options] section. |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 237 | |
David Shevitz | 7f9b34d | 2018-03-19 13:24:57 -0700 | [diff] [blame] | 238 | To see the options of your project: |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 239 | |
David Shevitz | 7f9b34d | 2018-03-19 13:24:57 -0700 | [diff] [blame] | 240 | . Go to the Gerrit Web UI. |
| 241 | . Click on the `Projects` > `List` menu entry. |
| 242 | . Find your project in the project list and click it. |
| 243 | . Click the `General` menu entry. |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 244 | |
| 245 | [[submit-type]] |
| 246 | === Submit Type |
| 247 | |
| 248 | An important decision for a project is the choice of the submit type |
Sebastian Schuberth | 774aac9 | 2015-04-16 13:21:04 +0200 | [diff] [blame] | 249 | and the content merge setting (see the `Allow content merges` option). |
Changcheng Xiao | 2188598 | 2019-01-15 18:16:51 +0100 | [diff] [blame] | 250 | The link:config-project-config.html#submit-type[submit type] is the method |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 251 | Gerrit uses to submit a change to the project. The submit type defines |
| 252 | what Gerrit should do on submit of a change if the destination branch |
| 253 | has moved while the change was in review. The |
Stefan Lay | 08ba473 | 2014-05-05 16:36:12 +0200 | [diff] [blame] | 254 | link:project-configuration.html#content_merge[content merge] setting applies |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 255 | if the same files have been modified concurrently and tells Gerrit |
| 256 | whether it should attempt a content merge for these files. |
| 257 | |
| 258 | When choosing the submit type and the content merge setting one must |
| 259 | weigh development comfort against the safety of not breaking the |
| 260 | destination branch. |
| 261 | |
| 262 | The most restrictive submit type is |
Stefan Lay | 08ba473 | 2014-05-05 16:36:12 +0200 | [diff] [blame] | 263 | link:project-configuration.html#fast_forward_only[Fast Forward Only]. Using |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 264 | this submit type means that after submitting one change all other open |
| 265 | changes for the same destination branch must be rebased manually. This |
| 266 | is quite burdensome and in practice only feasible for branches with |
| 267 | very few changes. On the other hand, if changes are verified before |
| 268 | submit, e.g. automatically by a CI integration, with this submit type, |
| 269 | you can be sure that the destination branch never gets broken. |
| 270 | |
Stefan Lay | 08ba473 | 2014-05-05 16:36:12 +0200 | [diff] [blame] | 271 | Choosing link:project-configuration.html#merge_if_necessary[Merge If Necessary] |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 272 | as submit type makes the life for developers more comfortable, |
| 273 | especially if content merge is enabled. If this submit strategy is used |
| 274 | developers only need to rebase manually if the same files have been |
| 275 | modified concurrently or if the content merge on such a file fails. The |
| 276 | drawback with this submit type is that there is a risk of breaking |
| 277 | the destination branch, e.g. if one change moves a class into another |
| 278 | package and another change imports this class from the old location. |
| 279 | Experience shows that in practice `Merge If Necessary` with content |
| 280 | merge enabled works pretty well and breaking the destination branch |
| 281 | happens rarely. This is why this setting is recommended at least for |
| 282 | development branches. You likely want to start with |
| 283 | `Merge If Necessary` with content merge enabled and only switch to a |
| 284 | more restrictive policy if you are facing issues with the build and |
| 285 | test stability of the destination branches. |
| 286 | |
Edwin Kempin | 1781adb | 2014-04-22 10:02:40 +0200 | [diff] [blame] | 287 | It is also possible to define the submit type dynamically via |
| 288 | link:#prolog-submit-type[Prolog]. This way you can use different submit |
| 289 | types for different branches. |
| 290 | |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 291 | Please note that there are other submit types available; they are |
Changcheng Xiao | 2188598 | 2019-01-15 18:16:51 +0100 | [diff] [blame] | 292 | described in the link:config-project-config.html#submit-type[Submit Type] |
Edwin Kempin | eaff6c1 | 2014-04-17 15:23:42 +0200 | [diff] [blame] | 293 | section. |
| 294 | |
Edwin Kempin | 1781adb | 2014-04-22 10:02:40 +0200 | [diff] [blame] | 295 | [[labels]] |
| 296 | == Labels |
| 297 | |
| 298 | The code review process includes that reviewers formally express their |
| 299 | opinion about a change by voting on different link:config-labels.html[ |
| 300 | labels]. By default Gerrit comes with the |
| 301 | link:config-labels.html#label_Code-Review[Code-Review] label and many |
| 302 | Gerrit servers have the link:config-labels.html#label_Verified[Verified] |
| 303 | label configured globally. However projects can also define their own |
| 304 | link:config-labels.html#label_custom[custom labels] to formalize |
| 305 | project-specific workflows. For example if a project requires an IP |
| 306 | approval from a special IP-team, it can define an `IP-Review` label |
| 307 | and grant permissions to the IP-team to vote on this label. |
| 308 | |
| 309 | The behavior of a label can be controlled by its |
| 310 | link:config-labels.html#label_function[function], e.g. it can be |
| 311 | configured whether a max positive voting on the label is required for |
| 312 | submit or if the voting on the label is optional. |
| 313 | |
| 314 | By using a custom link:#submit-rules[submit rule] it can be controlled |
| 315 | per change whether a label is required for submit or not. |
| 316 | |
| 317 | A useful feature on labels is the possibility to automatically copy |
| 318 | scores forward to new patch sets if it was a |
Edwin Kempin | 0ff9307 | 2022-04-05 14:25:11 +0200 | [diff] [blame] | 319 | link:config-labels.html#trivial_rebase[trivial rebase] or if |
| 320 | link:config-labels.html#no_code_change[there was no code change] (e.g. |
| 321 | only the commit message was edited). |
Edwin Kempin | 1781adb | 2014-04-22 10:02:40 +0200 | [diff] [blame] | 322 | |
| 323 | [[submit-rules]] |
| 324 | == Submit Rules |
| 325 | |
| 326 | A link:prolog-cookbook.html#SubmitRule[submit rule] in Gerrit is logic |
| 327 | that defines when a change is submittable. By default, a change is |
| 328 | submittable when it gets at least one highest vote on each label and |
| 329 | has no lowest vote (aka veto vote) on any label. |
| 330 | |
| 331 | The submit rules in Gerrit are implemented in link:prolog-cookbook.html[ |
| 332 | Prolog] and projects that need more flexibility can define their own |
| 333 | submit rules to decide when a change should be submittable. A good |
| 334 | link:prolog-cookbook.html#NonAuthorCodeReview[example] from the Prolog |
| 335 | cookbook shows how to allow submit only if a change has a |
| 336 | `Code-Review+2` vote from a person that is not the change author. This |
| 337 | way a four-eyes principle for the reviews can be enforced. |
| 338 | |
| 339 | A Prolog submit rule has access to link:prolog-change-facts.html[ |
| 340 | information] about the change for which it is testing the |
Eryk Szymanski | 2b93eb0 | 2016-11-15 17:56:28 -0800 | [diff] [blame] | 341 | submittability. Among others the list of the modified files can be |
Edwin Kempin | 1781adb | 2014-04-22 10:02:40 +0200 | [diff] [blame] | 342 | accessed, which allows special logic if certain files are touched. For |
| 343 | example, a common practice is to require a vote on an additional label, |
| 344 | like `Library-Compliance`, if the dependencies of the project are |
| 345 | changed. |
| 346 | |
| 347 | [[prolog-submit-type]] |
| 348 | It is also possible to control the link:prolog-cookbook.html#SubmitType[ |
| 349 | submit type] from Prolog. For example this can be used to define a more |
| 350 | restrictive submit type such as `Fast Forward Only` for stable branches |
| 351 | while using a more liberal submit type, e.g. `Merge If Necessary` with |
| 352 | content merge, for development branches. How this can be done can be |
| 353 | seen from an link:prolog-cookbook.html#SubmitTypePerBranch[example] in |
| 354 | the Prolog cookbook. |
| 355 | |
| 356 | Submit rules are maintained in the link:prolog-cookbook.html#RulesFile[ |
| 357 | rules.pl] file in the `refs/meta/config` branch of the project. How to |
| 358 | write submit rules is explained in the |
| 359 | link:prolog-cookbook.html#HowToWriteSubmitRules[Prolog cookbook]. There |
| 360 | is also good support for link:prolog-cookbook.html#TestingSubmitRules[ |
| 361 | testing submit rules] while developing them. |
| 362 | |
Edwin Kempin | 693888a | 2014-04-23 13:50:24 +0200 | [diff] [blame] | 363 | [[continuous-integration]] |
| 364 | == Continuous Integration |
| 365 | |
| 366 | With Gerrit you can have continuous integration builds not only for |
| 367 | updates of central branches but also whenever a new change/patch set is |
| 368 | uploaded for review. This way you get automatic verification of all |
| 369 | changes *before* they are merged and any build and test issues are |
| 370 | detected early. To indicate the build and test status the continuous |
| 371 | integration system normally votes with the |
| 372 | link:config-labels.html#label_Verified[Verified] label on the change. |
| 373 | |
| 374 | There are several solutions for integrating continuous integration |
| 375 | systems. The most commonly used are: |
| 376 | |
Edwin Kempin | 862b49e | 2022-07-13 10:48:45 +0200 | [diff] [blame] | 377 | - link:https://plugins.jenkins.io/gerrit-trigger/[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 378 | Gerrit Trigger,role=external,window=_blank] plugin for link:http://jenkins-ci.org/[Jenkins,role=external,window=_blank] |
Edwin Kempin | 693888a | 2014-04-23 13:50:24 +0200 | [diff] [blame] | 379 | |
| 380 | - link:http://www.mediawiki.org/wiki/Continuous_integration/Zuul[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 381 | Zuul,role=external,window=_blank] for link:http://jenkins-ci.org/[Jenkins,role=external,window=_blank] |
Edwin Kempin | 693888a | 2014-04-23 13:50:24 +0200 | [diff] [blame] | 382 | |
| 383 | For the integration with the continuous integration system you must |
| 384 | have a service user that is able to access Gerrit. To create a service |
| 385 | user in Gerrit you can use the link:cmd-create-account.html[create-account] |
| 386 | SSH command if the link:access-control.html#capability_createAccount[ |
| 387 | Create Account] global capability is granted. If not, you need to ask |
| 388 | a Gerrit administrator to create the service user. |
| 389 | |
David Pursehouse | 122f078 | 2018-09-28 13:45:23 +0900 | [diff] [blame] | 390 | If the link:https://gerrit-review.googlesource.com/admin/repos/plugins/serviceuser[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 391 | serviceuser,role=external,window=_blank] plugin is installed you can also create new service users |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 392 | in the Gerrit Web UI under `People` > `Create Service User`. For this |
Edwin Kempin | 5d6b9f1 | 2014-04-24 14:30:07 +0200 | [diff] [blame] | 393 | the `Create Service User` global capability must be assigned. |
Edwin Kempin | 693888a | 2014-04-23 13:50:24 +0200 | [diff] [blame] | 394 | |
| 395 | The service user must have link:access-control.html#category_read[read] |
| 396 | access to your project. In addition, if automatic change verification |
| 397 | is enabled, the service user must be allowed to vote on the |
| 398 | link:config-labels.html#label_Verified[Verified] label. |
| 399 | |
| 400 | Continuous integration systems usually integrate with Gerrit by |
| 401 | listening to the Gerrit link:cmd-stream-events.html#events[stream |
| 402 | events]. For this the service user must have the |
| 403 | link:access-control.html#capability_streamEvents[Stream Events] global |
| 404 | capability assigned. |
| 405 | |
Edwin Kempin | 7716775 | 2014-07-16 08:21:06 +0200 | [diff] [blame] | 406 | [[commit-validation]] |
| 407 | == Commit Validation |
| 408 | |
| 409 | Gerrit provides an |
| 410 | link:https://gerrit-review.googlesource.com/Documentation/config-validation.html#new-commit-validation[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 411 | extension point to do validation of new commits,role=external,window=_blank]. A Gerrit plugin |
Edwin Kempin | 7716775 | 2014-07-16 08:21:06 +0200 | [diff] [blame] | 412 | implementing this extension point can perform validation checks when |
| 413 | new commits are pushed to Gerrit. The plugin can either provide a |
| 414 | message to the client or reject the commit and cause the push to fail. |
| 415 | |
| 416 | There are some plugins available that provide commit validation: |
| 417 | |
David Pursehouse | 122f078 | 2018-09-28 13:45:23 +0900 | [diff] [blame] | 418 | - link:https://gerrit-review.googlesource.com/admin/repos/plugins/uploadvalidator[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 419 | uploadvalidator,role=external,window=_blank]: |
Edwin Kempin | 7716775 | 2014-07-16 08:21:06 +0200 | [diff] [blame] | 420 | + |
| 421 | The `uploadvalidator` plugin allows project owners to configure blocked |
| 422 | file extensions, required footers and a maximum allowed path length. |
| 423 | |
David Pursehouse | 122f078 | 2018-09-28 13:45:23 +0900 | [diff] [blame] | 424 | - link:https://gerrit-review.googlesource.com/admin/repos/plugins/commit-message-length-validator[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 425 | commit-message-length-validator,role=external,window=_blank] |
Edwin Kempin | 7716775 | 2014-07-16 08:21:06 +0200 | [diff] [blame] | 426 | + |
| 427 | The `commit-message-length-validator` core plugin validates that commit |
| 428 | messages conform to line length limits. |
| 429 | |
Edwin Kempin | 34f4f88 | 2014-04-22 16:13:18 +0200 | [diff] [blame] | 430 | [[branch-administration]] |
| 431 | == Branch Administration |
| 432 | |
| 433 | As project owner you can administrate the branches of your project in |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 434 | the Gerrit Web UI under `Projects` > `List` > <your project> > |
Hugo Arès | 5187d67 | 2018-03-19 13:04:01 -0400 | [diff] [blame] | 435 | `Branches`. In the Web UI link:project-configuration.html#branch-creation[ |
| 436 | branch creation] is allowed if you have |
| 437 | link:access-control.html#category_create[Create Reference] access right and |
| 438 | link:project-configuration.html#branch-deletion[branch deletion] is allowed if |
| 439 | you have the link:access-control.html#category_delete[Delete Reference] or the |
| 440 | link:access-control.html#category_push[Push] access right with the `force` |
| 441 | option. |
Edwin Kempin | 34f4f88 | 2014-04-22 16:13:18 +0200 | [diff] [blame] | 442 | |
| 443 | By setting `HEAD` on the project you can define its |
Stefan Lay | 08ba473 | 2014-05-05 16:36:12 +0200 | [diff] [blame] | 444 | link:project-configuration.html#default-branch[default branch]. For convenience |
Edwin Kempin | 34f4f88 | 2014-04-22 16:13:18 +0200 | [diff] [blame] | 445 | reasons, when the repository is cloned Git creates a local branch for |
| 446 | this default branch and checks it out. |
| 447 | |
Edwin Kempin | ef2b6af | 2014-04-22 11:04:10 +0200 | [diff] [blame] | 448 | [[notifications]] |
| 449 | == Email Notifications |
| 450 | |
| 451 | With Gerrit individual users control their own email subscriptions. By |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 452 | editing the link:user-notify.html#user[watched projects] in the Web UI |
Edwin Kempin | ef2b6af | 2014-04-22 11:04:10 +0200 | [diff] [blame] | 453 | under `Settings` > `Watched Projects` users can decide which events to |
| 454 | be informed about by email. The change notifications can be filtered by |
| 455 | link:user-search.html[change search expressions]. |
| 456 | |
| 457 | This means as a project owner you normally don't need to do anything |
| 458 | about email notifications, except maybe telling your project team where |
| 459 | to configure the watches. |
| 460 | |
| 461 | Gerrit also supports link:user-notify.html#project[notifications on |
| 462 | project level] that allow project owners to set up email notifications |
| 463 | for team mailing lists or groups of users. This configuration is done |
| 464 | in the `project.config` file in the `refs/meta/config` branch as |
| 465 | explained in the section about link:user-notify.html#project[project |
| 466 | level notifications]. |
| 467 | |
Edwin Kempin | 09c4960 | 2014-04-22 11:33:00 +0200 | [diff] [blame] | 468 | [[dashboards]] |
| 469 | == Dashboards |
| 470 | |
| 471 | Gerrit comes with a pre-defined user dashboard that provides a view |
| 472 | of the changes that are relevant for a user. Users can also define |
| 473 | their own link:user-dashboards.html[custom dashboards] where the |
| 474 | dashboard sections can be freely configured. As a project owner you can |
| 475 | configure such custom dashboards on |
| 476 | link:user-dashboards.html#project-dashboards[project level]. This way |
| 477 | you can define a view of the changes that are relevant for your |
| 478 | project and share this dashboard with all users. The project dashboards |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 479 | can be seen in the Web UI under `Projects` > `List` > <your project> > |
Edwin Kempin | 09c4960 | 2014-04-22 11:33:00 +0200 | [diff] [blame] | 480 | `Dashboards`. |
| 481 | |
Edwin Kempin | 96cdad4 | 2014-04-22 13:30:56 +0200 | [diff] [blame] | 482 | [[issue-tracker-integration]] |
| 483 | == Issue Tracker Integration |
| 484 | |
| 485 | There are several possibilities to integrate issue trackers with |
| 486 | Gerrit. |
| 487 | |
| 488 | - Comment Links |
| 489 | + |
Edwin Kempin | 8691f5a | 2014-04-30 09:21:57 +0200 | [diff] [blame] | 490 | As described in the link:#comment-links[Comment Links] section, comment |
Edwin Kempin | 96cdad4 | 2014-04-22 13:30:56 +0200 | [diff] [blame] | 491 | links can be used to link IDs from commit message footers to issues in |
| 492 | an issue tracker system. |
| 493 | |
| 494 | - Tracking IDs |
| 495 | + |
| 496 | Gerrit can be configured to index IDs from commit message footers so |
| 497 | that the link:user-search.html#tr[tr/bug] search operators can be used |
| 498 | to query for changes with a certain ID. The |
| 499 | link:config-gerrit.html#trackingid[configuration of tracking IDs] can |
| 500 | only be done globally by a Gerrit administrator. |
| 501 | |
| 502 | - Issue Tracker System Plugins |
| 503 | + |
| 504 | There are Gerrit plugins for a tight integration with |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 505 | link:https://gerrit-review.googlesource.com//admin/repos/plugins/its-jira[Jira,role=external,window=_blank], |
| 506 | link:https://gerrit-review.googlesource.com/admin/repos/plugins/its-bugzilla[Bugzilla,role=external,window=_blank] and |
| 507 | link:https://gerrit-review.googlesource.com/admin/repos/plugins/its-rtc[IBM Rational Team Concert,role=external,window=_blank]. |
Edwin Kempin | 96cdad4 | 2014-04-22 13:30:56 +0200 | [diff] [blame] | 508 | If installed, these plugins can e.g. be used to automatically add links |
| 509 | to Gerrit changes to the issues in the issue tracker system or to |
| 510 | automatically close an issue if the corresponding change is merged. |
| 511 | If installed, project owners may enable/disable the issue tracker |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 512 | integration from the Gerrit Web UI under `Projects` > `Lists` > |
Edwin Kempin | 96cdad4 | 2014-04-22 13:30:56 +0200 | [diff] [blame] | 513 | <your project> > `General`. |
| 514 | |
| 515 | [[comment-links]] |
| 516 | == Comment Links |
| 517 | |
| 518 | Gerrit can linkify strings in commit messages, summary comments and |
| 519 | inline comments. A string that matches a defined regular expression is |
| 520 | then displayed as hyperlink to a configured backend system. |
| 521 | |
| 522 | So called comment links can be configured globally by a Gerrit |
| 523 | administrator, but also per project by the project owner. Comment links |
| 524 | on project level are defined in the `project.config` file in the |
| 525 | `refs/meta/config` branch of the project as described in the |
| 526 | documentation of the link:config-gerrit.html#commentlink[commentlink] |
| 527 | configuration parameter. |
| 528 | |
| 529 | Often comment links are used to link an ID in a commit message footer |
| 530 | to an issue in an issue tracker system. For example, to link the ID |
| 531 | from the `Bug` footer to Jira the following configuration can be used: |
| 532 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 533 | ---- |
Edwin Kempin | 96cdad4 | 2014-04-22 13:30:56 +0200 | [diff] [blame] | 534 | [commentlink "myjira"] |
| 535 | match = ([Bb][Uu][Gg]:\\s+)(\\S+) |
| 536 | link = https://myjira/browse/$2 |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 537 | ---- |
Edwin Kempin | 96cdad4 | 2014-04-22 13:30:56 +0200 | [diff] [blame] | 538 | |
Edwin Kempin | 5d80395 | 2014-04-24 14:19:42 +0200 | [diff] [blame] | 539 | [[reviewers]] |
| 540 | == Reviewers |
| 541 | |
| 542 | Normally it is not needed to explicitly assign reviewers to every |
| 543 | change since the project members either link:user-notify.html#user[ |
| 544 | watch the project] and get notified by email or regularly check the |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 545 | list of open changes in the Gerrit Web UI. The project members then |
Edwin Kempin | 5d80395 | 2014-04-24 14:19:42 +0200 | [diff] [blame] | 546 | pick the changes themselves that are interesting to them for review. |
| 547 | |
| 548 | If authors of changes want to have a review by a particular person |
| 549 | (e.g. someone who is known to be expert in the touched code area, or a |
| 550 | stakeholder for the implemented feature), they can request the review |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 551 | by adding this person in the Gerrit Web UI as a reviewer on the change. |
Edwin Kempin | 5d80395 | 2014-04-24 14:19:42 +0200 | [diff] [blame] | 552 | Gerrit will then notify this person by email about the review request. |
| 553 | |
David Pursehouse | 122f078 | 2018-09-28 13:45:23 +0900 | [diff] [blame] | 554 | With the link:https://gerrit-review.googlesource.com/admin/repos/plugins/reviewers[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 555 | reviewers,role=external,window=_blank] plugin it is possible to configure default reviewers who |
Edwin Kempin | 5d80395 | 2014-04-24 14:19:42 +0200 | [diff] [blame] | 556 | will be automatically added to each change. The default reviewers can |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 557 | be configured in the Gerrit Web UI under `Projects` > `List` > |
Edwin Kempin | 5d80395 | 2014-04-24 14:19:42 +0200 | [diff] [blame] | 558 | <your project> > `General` in the `reviewers Plugin` section. |
| 559 | |
David Pursehouse | 122f078 | 2018-09-28 13:45:23 +0900 | [diff] [blame] | 560 | The link:https://gerrit-review.googlesource.com/admin/repos/plugins/reviewers-by-blame[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 561 | reviewers-by-blame,role=external,window=_blank] plugin can automatically add reviewers to changes |
Edwin Kempin | 5d80395 | 2014-04-24 14:19:42 +0200 | [diff] [blame] | 562 | based on the link:https://www.kernel.org/pub/software/scm/git/docs/git-blame.html[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 563 | git blame,role=external,window=_blank] computation on the changed files. This means that the plugin |
Edwin Kempin | 5d80395 | 2014-04-24 14:19:42 +0200 | [diff] [blame] | 564 | will add those users as reviewer that authored most of the lines |
| 565 | touched by the change, since these users should be familiar with the |
| 566 | code and can most likely review the change. How many reviewers the |
| 567 | plugin will add to a change at most can be configured in the Gerrit |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 568 | Web UI under `Projects` > `List` > <your project> > `General` in the |
Edwin Kempin | 5d80395 | 2014-04-24 14:19:42 +0200 | [diff] [blame] | 569 | `reviewers-by-blame Plugin` section. |
| 570 | |
Edwin Kempin | e622b79 | 2014-04-23 13:06:57 +0200 | [diff] [blame] | 571 | [[download-commands]] |
| 572 | == Download Commands |
| 573 | |
| 574 | On the change screen in the `Downloads` drop-down panel Gerrit offers |
| 575 | commands for downloading the currently viewed patch set. |
| 576 | |
| 577 | The download commands are implemented by Gerrit plugins. This means |
| 578 | that the available download commands depend on the installed Gerrit |
| 579 | plugins: |
| 580 | |
David Pursehouse | 122f078 | 2018-09-28 13:45:23 +0900 | [diff] [blame] | 581 | - link:https://gerrit-review.googlesource.com/admin/repos/plugins/download-commands[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 582 | download-commands,role=external,window=_blank] plugin: |
Edwin Kempin | e622b79 | 2014-04-23 13:06:57 +0200 | [diff] [blame] | 583 | + |
| 584 | The `download-commands` plugin provides the default download commands |
| 585 | (`Checkout`, `Cherry Pick`, `Format Patch` and `Pull`). |
| 586 | + |
| 587 | Gerrit administrators may configure which of the commands are shown on |
| 588 | the change screen. |
| 589 | |
David Pursehouse | 122f078 | 2018-09-28 13:45:23 +0900 | [diff] [blame] | 590 | - link:https://gerrit-review.googlesource.com/admin/repos/plugins/project-download-commands[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 591 | project-download-commands,role=external,window=_blank] plugin: |
Edwin Kempin | e622b79 | 2014-04-23 13:06:57 +0200 | [diff] [blame] | 592 | + |
| 593 | The `project-download-commands` plugin enables project owners to |
| 594 | configure project-specific download commands. For example, a |
| 595 | project-specific download command may update submodules, trigger a |
| 596 | build, execute the tests or even do a deployment. |
| 597 | + |
| 598 | The project-specific download commands must be configured in the |
| 599 | `project.config` file in the `refs/meta/config` branch of the project: |
| 600 | + |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 601 | ---- |
Edwin Kempin | e622b79 | 2014-04-23 13:06:57 +0200 | [diff] [blame] | 602 | [plugin "project-download-commands"] |
David Ostrovsky | fdbfcad | 2016-11-15 06:35:29 -0800 | [diff] [blame] | 603 | Build = git fetch ${url} ${ref} && git checkout FETCH_HEAD && bazel build ${project} |
Edwin Kempin | e622b79 | 2014-04-23 13:06:57 +0200 | [diff] [blame] | 604 | Update = git fetch ${url} ${ref} && git checkout FETCH_HEAD && git submodule update |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 605 | ---- |
Edwin Kempin | e622b79 | 2014-04-23 13:06:57 +0200 | [diff] [blame] | 606 | + |
| 607 | Project-specific download commands that are defined on a parent project |
| 608 | are inherited by the child projects. A child project can overwrite an |
| 609 | inherited download command, or remove it by assigning no value to it. |
Edwin Kempin | 96cdad4 | 2014-04-22 13:30:56 +0200 | [diff] [blame] | 610 | |
Edwin Kempin | 1519979 | 2014-04-23 16:22:05 +0200 | [diff] [blame] | 611 | [[tool-integration]] |
| 612 | == Integration with other tools |
| 613 | |
| 614 | Gerrit provides many possibilities for the integration with other |
| 615 | tools: |
| 616 | |
| 617 | - Stream Events: |
| 618 | + |
| 619 | The link:cmd-stream-events.html[stream-events] SSH command allows to |
| 620 | listen to Gerrit link:cmd-stream-events.html#events[events]. Other |
| 621 | tools can use this to react on actions done in Gerrit. |
| 622 | + |
| 623 | The link:access-control.html#capability_streamEvents[Stream Events] |
| 624 | global capability is required for using the `stream-events` command. |
| 625 | |
| 626 | - REST API: |
| 627 | + |
| 628 | Gerrit provides a rich link:rest-api.html[REST API] that other tools |
| 629 | can use to query information from Gerrit and and to trigger actions in |
| 630 | Gerrit. |
| 631 | |
| 632 | - Gerrit Plugins: |
| 633 | + |
| 634 | The Gerrit functionality can be extended by plugins and there are many |
| 635 | extension points, e.g. plugins can |
| 636 | + |
Ben Rohlfs | da0a62b | 2021-04-26 17:02:19 +0200 | [diff] [blame] | 637 | ** link:pg-plugin-admin-api.html[add new menu entries] |
| 638 | ** link:pg-plugin-endpoints.html[hook into DOM elements] and |
| 639 | link:pg-plugin-dev.html#plugin-screen[add new pages] |
Edwin Kempin | 1519979 | 2014-04-23 16:22:05 +0200 | [diff] [blame] | 640 | ** link:config-validation.html[do validation], e.g. of new commits |
| 641 | ** add new REST endpoints and link:dev-plugins.html#ssh[SSH commands] |
| 642 | |
| 643 | + |
| 644 | How to develop a Gerrit plugin is described in the link:dev-plugins.html[ |
| 645 | Plugin Development] section. |
| 646 | |
David Pursehouse | a61ee50 | 2016-09-06 16:27:09 +0900 | [diff] [blame] | 647 | [[project-lifecycle]] |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 648 | == Project Lifecycle |
| 649 | |
| 650 | [[project-creation]] |
| 651 | === Project Creation |
| 652 | |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 653 | New projects can be created in the Gerrit Web UI under `Projects` > |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 654 | `Create Project`. The `Create Project` menu entry is only available if |
| 655 | you have the link:access-control.html#capability_createProject[ |
| 656 | Create Project] global capability assigned. |
| 657 | |
| 658 | Projects can also be created via REST or SSH as described in the |
Stefan Lay | 08ba473 | 2014-05-05 16:36:12 +0200 | [diff] [blame] | 659 | link:project-configuration.html#project-creation[Project Setup] section. |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 660 | |
| 661 | Creating the project with an initial empty commit is generally |
| 662 | recommended because some tools have issues with cloning repositories |
| 663 | that are completely empty. However, if you plan to link:#import-history[ |
| 664 | import an existing history] into the new project, it is better to |
| 665 | create the project without an initial empty commit. |
| 666 | |
| 667 | [[import-history]] |
| 668 | === Import Existing History |
| 669 | |
| 670 | If you have an existing history you can import it into a Gerrit |
| 671 | project. To do this you need to have a local Git repository that |
| 672 | contains this history. If your existing codebase is in another VCS you |
| 673 | must migrate it to Git first. For Subversion you can use the |
| 674 | link:http://git-scm.com/book/en/Git-and-Other-Systems-Git-and-Subversion[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 675 | git svn,role=external,window=_blank] command as described in the |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 676 | link:http://git-scm.com/book/en/Git-and-Other-Systems-Migrating-to-Git#Subversion[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 677 | Subversion migration guide,role=external,window=_blank]. An importer for Perforce is available in |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 678 | the `contrib` section of the Git source code; how to use |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 679 | link:http://git-scm.com/docs/git-p4[git p4,role=external,window=_blank] to do the import from |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 680 | Perforce is described in the |
| 681 | link:http://git-scm.com/book/en/Git-and-Other-Systems-Migrating-to-Git#Perforce[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 682 | Perforce migration guide,role=external,window=_blank]. |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 683 | |
| 684 | To import an existing history into a Gerrit project you bypass code |
| 685 | review and push it directly to `refs/heads/<branch>`. For this you must |
| 686 | have the corresponding link:access-control.html#category_push_direct[ |
| 687 | Push] access right assigned. If the destination branch in the Gerrit |
| 688 | repository already contains a history (e.g. an initial empty commit), |
| 689 | you can overwrite it by doing a force push. In this case force push |
| 690 | must be allowed in the access controls of the project. |
| 691 | |
| 692 | Some Gerrit servers may disallow forging committers by blocking the |
| 693 | link:access-control.html#category_forge_committer[Forge Committer] |
| 694 | access right globally. In this case you must use the |
| 695 | link:https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 696 | git filter-branch,role=external,window=_blank] command to rewrite the committer information for all |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 697 | commits (the author information that records who was writing the code |
| 698 | stays intact; signed tags will lose their signature): |
| 699 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 700 | ---- |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 701 | $ git filter-branch --tag-name-filter cat --env-filter 'GIT_COMMITTER_NAME="John Doe"; GIT_COMMITTER_EMAIL="john.doe@example.com";' -- --all |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 702 | ---- |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 703 | |
| 704 | If a link:config-gerrit.html#receive.maxObjectSizeLimit[max object size |
| 705 | limit] is configured on the server you may need to remove large objects |
| 706 | from the history before you are able to push. To find large objects in |
Edwin Kempin | 5ba27bd | 2014-05-09 14:53:04 +0200 | [diff] [blame] | 707 | the history of your project you can use the `reposize.sh` script which |
| 708 | you can download from Gerrit: |
| 709 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 710 | ---- |
Edwin Kempin | 5ba27bd | 2014-05-09 14:53:04 +0200 | [diff] [blame] | 711 | $ curl -Lo reposize.sh http://review.example.com:8080/tools/scripts/reposize.sh |
| 712 | |
| 713 | or |
| 714 | |
| 715 | $ scp -p -P 29418 john.doe@review.example.com:scripts/reposize.sh . |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 716 | ---- |
Edwin Kempin | 5ba27bd | 2014-05-09 14:53:04 +0200 | [diff] [blame] | 717 | |
| 718 | You can then use the |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 719 | link:https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html[ |
| 720 | git filter-branch] command to remove the large objects from the history |
| 721 | of all branches: |
| 722 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 723 | ---- |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 724 | $ git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch path/to/large-file.jar' -- --all |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 725 | ---- |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 726 | |
| 727 | Since this command rewrites all commits in the repository it's a good |
| 728 | idea to create a fresh clone from this rewritten repository before |
| 729 | pushing to Gerrit, this will ensure that the original objects which |
| 730 | have been rewritten are removed. |
| 731 | |
| 732 | [[project-deletion]] |
| 733 | === Project Deletion |
| 734 | |
| 735 | Gerrit core does not support the deletion of projects. |
| 736 | |
David Pursehouse | 122f078 | 2018-09-28 13:45:23 +0900 | [diff] [blame] | 737 | If the link:https://gerrit-review.googlesource.com/admin/repos/plugins/delete-project[ |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 738 | delete-project,role=external,window=_blank] plugin is installed, projects can be deleted from the |
David Pursehouse | a1d633b | 2014-05-02 17:21:02 +0900 | [diff] [blame] | 739 | Gerrit Web UI under `Projects` > `List` > <project> > `General` by |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 740 | clicking on the `Delete` command under `Project Commands`. The `Delete` |
Edwin Kempin | 56bac94 | 2014-04-24 14:25:42 +0200 | [diff] [blame] | 741 | command is only available if you have the `Delete Projects` global |
| 742 | capability assigned, or if you own the project and you have the |
| 743 | `Delete Own Projects` global capability assigned. If neither of these |
| 744 | capabilities is granted, you need to contact a Gerrit administrator to |
| 745 | request the deletion of your project. |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 746 | |
| 747 | Instead of deleting a project you may set the |
Stefan Lay | 08ba473 | 2014-05-05 16:36:12 +0200 | [diff] [blame] | 748 | link:project-configuration.html#project-state[project state] to `ReadOnly` or |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 749 | `Hidden`. |
| 750 | |
| 751 | [[project-rename]] |
| 752 | === Project Rename |
| 753 | |
| 754 | Gerrit core does not support the renaming of projects. |
| 755 | |
Matthias Sohn | 536f002 | 2020-02-17 16:08:12 +0100 | [diff] [blame] | 756 | If the link:https://gerrit-review.googlesource.com/admin/repos/plugins/rename-project[rename-project] |
| 757 | plugin is installed, projects can be renamed using the |
| 758 | link:https://gerrit.googlesource.com/plugins/rename-project/+/refs/heads/master/src/main/resources/Documentation/cmd-rename.md[rename-project] |
Marco Miller | e055613 | 2020-02-18 14:38:04 -0500 | [diff] [blame] | 759 | ssh command. |
| 760 | |
| 761 | Find details about prerequisites in the |
Matthias Sohn | 536f002 | 2020-02-17 16:08:12 +0100 | [diff] [blame] | 762 | link:https://gerrit.googlesource.com/plugins/rename-project/+/refs/heads/master/src/main/resources/Documentation/about.md[plugin documentation]. |
| 763 | |
| 764 | If you don't want to use the rename-project plugin you can perform the following steps as |
| 765 | a workaround: |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 766 | |
David Shevitz | 7f9b34d | 2018-03-19 13:24:57 -0700 | [diff] [blame] | 767 | . link:#project-creation[Create a new project] with the new name. |
| 768 | . link:#import-history[Import the history of the old project]. |
| 769 | . link:#project-deletion[Delete the old project]. |
Edwin Kempin | f2b47e2 | 2014-04-24 13:00:28 +0200 | [diff] [blame] | 770 | |
Edwin Kempin | ec86ca1 | 2015-04-17 10:03:30 +0200 | [diff] [blame] | 771 | Please note that a drawback of this workaround is that the whole review |
| 772 | history (changes, review comments) is lost. |
| 773 | |
Edwin Kempin | 4bf0196 | 2014-04-16 16:47:10 +0200 | [diff] [blame] | 774 | GERRIT |
| 775 | ------ |
| 776 | Part of link:index.html[Gerrit Code Review] |
| 777 | |
| 778 | SEARCHBOX |
| 779 | --------- |