aboutsummaryrefslogtreecommitdiffstats
path: root/docs/contributing/gitreview.rst
blob: b2608d11812b49d71039d4e5afae1f35ce0035ed (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
.. _gitreview:

*******************************
Getting a Patch Reviewed
*******************************

This section describes how to get FD.io VPP sources reviewed and merged.

Setup
========

If you don't have a Linux Foundation ID, `create one here. <https://identity.linuxfoundation.org/>`_

With your Linux Foundation ID credentials sign into `Gerrit Code Review at gerrit.fd.io <https://gerrit.fd.io/r/login/%23%2Fq%2Fstatus%3Aopen>`_

`Install git-review, <https://www.mediawiki.org/wiki/Gerrit/git-review>`_ which is a "command-line tool for Git / Gerrit to submit a change or to fetch an existing one."

If you're on Ubuntu, install keychain:

.. code-block:: console

    $ sudo apt-get install keychain

ssh keys
-------------

To get FD.io VPP documents reviewed the VPP repository should be cloned with ssh. You should be logged into Gerrit Code Review as noted above.

Create your public and private ssh key with:

.. code-block:: console

    $ ssh-keygen -t rsa
    $ keychain
    $ cat ~/.ssh/id_rsa.pub

Copy **all** the contents of the public key (id_rsa.pub) output by the above **cat** command. Then go to your `SSH Public keys settings page <https://gerrit.fd.io/r/#/settings/ssh-keys>`_, click **Add Key ...**, paste your public key, and finally click **Add**.

.. _clone-ssh:

Clone with ssh
==============

Clone the repo with:

.. code-block:: console

    $ git clone ssh://gerrit.fd.io:29418/vpp
    $ cd vpp

This will only work if the name of the user on your system matches your Gerrit username.

Otherwise, clone with:

.. code-block:: console

    $ git clone ssh://<YOUR_GERRIT_USERNAME>@gerrit.fd.io:29418/vpp
    $ cd vpp

When attempting to clone the repo Git will prompt you asking if you want to add the Server Host Key to the list of known hosts. Enter **yes** and press the **Enter** key.

Git Review
===========

The VPP documents use the gerrit server, and git review for submitting and fetching patches.


New patch
-----------------

When working with a new patch, use the following commands to get your patch reviewed.

Make sure you have modified the correct files by issuing the following commands:

.. code-block:: console

    $ git status
    $ git diff

Then add and commit the patch. You may want to add a tag to the commit comments.
For example for a document with only patches you should add the tag **docs:**.

.. code-block:: console

    $ git add <filename>
    $ git commit -s

The commit comment should have something like the following comment:

.. code-block:: console

   docs: A brief description of the commit

   Type: Improvement (The type of commit this could be: Improvement, Fix or Feature)

   A detailed description of the commit could go here.

Push the patch for review.

.. code-block:: console

    $ git review

If you are creating a draft, meaning you do not want your changes reviewed yet, do the following:

.. code-block:: console

    $ git review -D

After submitting a review, reset where the HEAD is pointing to with:

.. code-block:: console

    $ git reset --hard origin/master

Existing patch
-----------------------

The "change number" used below is in the URL of the review.

After clicking an individual review, the change number can be found in the URL at "https://gerrit.fd.io/r/#/c/<*CHANGE_NUMBER*>/"

To view an existing patch:

.. code-block:: console

    $ git review -d <change number>
    $ git status
    $ git diff

.. caution::

    If you have made changes and do "git review -d <change number>", your current
    changes will try to be stashed so that the working tree can change to the review branch
    you specified. If you want to make sure you don't lose your changes, clone another Gerrit
    repo into a new directory using the cloning steps shown in :ref:`clone-ssh`, and perform
    "git review -d <change number>" in this new directory.

To modify an existing patch, make sure you modified the correct files, and apply the patch with:

.. code-block:: console

    $ git review -d <change number>
    $ git status
    $ git diff

    $ git add <filename>
    $ git commit --amend
    $ git review

When you're done viewing or modifying a branch, get back to the master branch by entering:

.. code-block:: console

    $ git reset --hard origin/master
    $ git checkout master

Patch Conflict Resolution
-------------------------

Two different patch conflict scenarios arise from time to
time. Sometime after uploading a patch to https://gerrit.fd.io, the
gerrit UI may show a patch status of "Merge Conflict."

Or, you may attempt to upload a new patch-set via "git review," only to
discover that the gerrit server won't allow the upload due to an upstream
merge conflict.

In both cases, it's [usually] fairly simple to fix the problem. You
need to rebase the patch onto master/latest. Details vary from case to
case.

Here's how to rebase a patch previously uploaded to the Gerrit server
which now has a merge conflict. In a fresh workspace cloned from
master/latest, do the following:

.. code-block:: console

    $ git-review -d <*Gerrit change #*>
    $ git rebase origin/master
       while (conflicts)
          <fix conflicts>
          $ git rebase --continue
    $ git review

In the upload-failure case, use caution: carefully **save your work**
before you do anything else!

Rebase your patch and try again. Please **do not** re-download ["git
review -d"] the patch from the gerrit server...:

.. code-block:: console

    $ git rebase origin/master
       while (conflicts)
          <fix conflicts>
          $ git rebase --continue
    $ git review