aboutsummaryrefslogtreecommitdiffstats
path: root/docs/5_How_To_Contribute/3_Working_with_Gerrit.md
blob: 8bba660c5fe41a81efe195752d97302b99e12499 (plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
title: Working with Gerrit
---

Follow these instructions to collaborate on AGL through the Gerrit review system.

Please be sure that you are subscribed to the [mailing
list](https://lists.automotivelinux.org/g/agl-dev-community) and of
course, you can reach out on IRC at the #automotive channel on
Freenode.net

Gerrit assigns the following roles to users:

-  **Submitters**: May submit changes for consideration, review other
   code changes, and make recommendations for acceptance or rejection by
   voting +1 or -1, respectively.
-  **Maintainers**: May approve or reject changes based upon feedback
   from reviewers voting +2 or -2, respectively.

## Getting deeper into Gerrit

A comprehensive walk-through of Gerrit is beyond the scope of this
document. There are plenty of resources available on the Internet. A good
summary can be found
[here](https://www.mediawiki.org/wiki/Gerrit/Tutorial) and 
[Basic Gerrit Walkthrough for GitHub Users](https://gerrit-review.googlesource.com/Documentation/intro-gerrit-walkthrough-github.html).

## Working with a local clone of the repository

To work on something, whether a new feature or a bugfix:

1. Open the Gerrit [repo page](https://gerrit.automotivelinux.org/gerrit/admin/repos/).

2. Select the repository you wish to work on.

3. Open a terminal window and clone the project locally using the
   ``Clone with git hook`` URL. Be sure that ``ssh`` is also selected,
   as this will make authentication much simpler. For example, for `documentation` repository:

    ```sh
    $ git clone "ssh://<LFID>@gerrit.automotivelinux.org:29418/AGL/documentation" && scp -p -P
    29418 <LFID>@gerrit.automotivelinux.org:hooks/commit-msg "documentation/.git/hooks/"
    ```

4. Setup `user` and `email` for git config

    ```sh
     $ cd documentation
     $ git.config --global user.name "Your Full Name"
     $ git config --global user.email "your@email.com"
    ```

      **NOTE:** To only configure for a particular repository :

    ```sh
     $ cd documentation
     $ git.config user.name "Your Full Name"
     $ git config user.email "your@email.com"
    ```

5. Create a descriptively-named branch off of your cloned repository

    ```sh
     $ git checkout -b issue-nname
    ```

## Using git review

There's a **very** useful tool for working with Gerrit called [git-review](https://www.mediawiki.org/wiki/Gerrit/git-review). This command-line tool can automate most of the ensuing sections for you. Ofcourse, reading the information below is also highly recommended so that you understand what's going on behind the scenes.

```sh
# for first time use only
$ git review -s
```
If `.gitreview` is missing, add the following section to ``.git/config``, and replace ``<LFID>``
with your LFID id.

```sh
[remote "gerrit"]
   url = ssh://<LFID>@gerrit.automotivelinux.org:29418/AGL/documentation.git
   fetch = +refs/heads/*:refs/remotes/gerrit/*
```

Then submit your change with ``git review``.

```sh
$ cd documentation
$ git review
```

When you update your patch, you can commit with ``git commit --amend``,
and then repeat the ``git review`` command.

## Typical Review Workflow

   - New Fresh Change

      ```sh
      $ cd documentation                              # Working Repository
      $ git remote -v update                          # Updating wrt remote
      $ git checkout -b mytopicbranch origin/master   # Creating new branch
      ### CODE the CHANGES
      $ git add  <file>                               # Track the changed files
      $ git commit -s                                 # Signed Commit Message
      $ git review                                    # Submit Changes to review
      ```

   - Updating existing Gerrit Review

      ```sh
      $ cd documentation                              # Working Repository
      $ git review -d 25678                           # Download review, 25678 is change number
      ### CODE the CHANGES
      $ git add  <file>                               # Track the changed files
      $ git commit -s                                 # Signed Commit Message
      $ git review                                    # Submit Changes to review
      $ git checkout master                           # Return to master branch
      ```

## Reviewing Using Gerrit

-  **Add**: This button allows the change submitter to manually add
   names of people who should review a change; start typing a name and
   the system will auto-complete based on the list of people registered
   and with access to the system. They will be notified by email that
   you are requesting their input.

-  **Abandon**: This button is available to the submitter only; it
   allows a committer to abandon a change and remove it from the merge
   queue.

-  **Change-ID**: This ID is generated by Gerrit (or system). It becomes
   useful when the review process determines that your commit(s) have to
   be amended. You may submit a new version; and if the same Change-ID
   header (and value) are present, Gerrit will remember it and present
   it as another version of the same change.

-  **Status**: Currently, the example change is in review status, as
   indicated by “Needs Verified” in the upper-left corner. The list of
   Reviewers will all emit their opinion, voting +1 if they agree to the
   merge, -1 if they disagree. Gerrit users with a Maintainer role can
   agree to the merge or refuse it by voting +2 or -2 respectively.

Notifications are sent to the email address in your commit message's
Signed-off-by line. Visit your [Gerrit dashboard](https://gerrit.automotivelinux.org/gerrit/dashboard/self),
to check the progress of your requests.

The history tab in Gerrit will show you the in-line comments and the author of the review.