github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/docs/source/Gerrit/gerrit.rst (about)

     1  Working with Gerrit
     2  ===================
     3  
     4  Follow these instructions to collaborate on Hyperledger Fabric
     5  through the Gerrit review system.
     6  
     7  Please be sure that you are subscribed to the `mailing
     8  list <http://lists.hyperledger.org/mailman/listinfo/hyperledger-fabric>`__
     9  and of course, you can reach out on
    10  `chat <https://chat.hyperledger.org/>`__ if you need help.
    11  
    12  Gerrit assigns the following roles to users:
    13  
    14  -  **Submitters**: May submit changes for consideration, review other
    15     code changes, and make recommendations for acceptance or rejection by
    16     voting +1 or -1, respectively.
    17  -  **Maintainers**: May approve or reject changes based upon feedback
    18     from reviewers voting +2 or -2, respectively.
    19  -  **Builders**: (e.g. Jenkins) May use the build automation
    20     infrastructure to verify the change.
    21  
    22  Maintainers should be familiar with the :doc:`review
    23  process <reviewing>`. However, anyone is welcome to (and
    24  encouraged!) review changes, and hence may find that document of value.
    25  
    26  Git-review
    27  ----------
    28  
    29  There's a **very** useful tool for working with Gerrit called
    30  `git-review <https://www.mediawiki.org/wiki/Gerrit/git-review>`__. This
    31  command-line tool can automate most of the ensuing sections for you. Of
    32  course, reading the information below is also highly recommended so that
    33  you understand what's going on behind the scenes.
    34  
    35  Sandbox project
    36  ---------------
    37  
    38  We have created a `sandbox
    39  project <https://gerrit.hyperledger.org/r/#/admin/projects/lf-sandbox>`__
    40  to allow developers to familiarize themselves with Gerrit and our
    41  workflows. Please do feel free to use this project to experiment with
    42  the commands and tools, below.
    43  
    44  Getting deeper into Gerrit
    45  --------------------------
    46  
    47  A comprehensive walk-through of Gerrit is beyond the scope of this
    48  document. There are plenty of resources available on the Internet. A
    49  good summary can be found
    50  `here <https://www.mediawiki.org/wiki/Gerrit/Tutorial>`__. We have also
    51  provided a set of :doc:`Best Practices <best-practices>` that you may
    52  find helpful.
    53  
    54  Working with a local clone of the repository
    55  --------------------------------------------
    56  
    57  To work on something, whether a new feature or a bugfix:
    58  
    59  1. Open the Gerrit `Projects
    60     page <https://gerrit.hyperledger.org/r/#/admin/projects/>`__
    61  
    62  2. Select the project you wish to work on.
    63  
    64  3. Open a terminal window and clone the project locally using the
    65     ``Clone with git hook`` URL. Be sure that ``ssh`` is also selected,
    66     as this will make authentication much simpler:
    67  
    68     ::
    69  
    70         git clone ssh://LFID@gerrit.hyperledger.org:29418/fabric && scp -p -P 29418 LFID@gerrit.hyperledger.org:hooks/commit-msg fabric/.git/hooks/
    71  
    72  **Note:** if you are cloning the fabric project repository, you will
    73  want to clone it to the ``$GOPATH/src/github.com/hyperledger`` directory
    74  so that it will build, and so that you can use it with the Vagrant
    75  :doc:`development environment <../dev-setup/devenv>`.
    76  
    77  4. Create a descriptively-named branch off of your cloned repository
    78  
    79  ::
    80  
    81      cd fabric
    82      git checkout -b issue-nnnn
    83  
    84  5. Commit your code. For an in-depth discussion of creating an effective
    85     commit, please read :doc:`this document on submitting changes <changes>`.
    86  
    87  ::
    88  
    89      git commit -s -a
    90  
    91  Then input precise and readable commit msg and submit.
    92  
    93  6. Any code changes that affect documentation should be accompanied by
    94     corresponding changes (or additions) to the documentation and tests.
    95     This will ensure that if the merged PR is reversed, all traces of the
    96     change will be reversed as well.
    97  
    98  Submitting a Change
    99  -------------------
   100  
   101  Currently, Gerrit is the only method to submit a change for review.
   102  
   103  **Note:** Please review the :doc:`guidelines <changes>` for making and
   104  submitting a change.
   105  
   106  Use git review
   107  ~~~~~~~~~~~~~~
   108  
   109  **Note:** if you prefer, you can use the `git-review <#git-review>`__
   110  tool instead of the following. e.g.
   111  
   112  Add the following section to ``.git/config``, and replace ``<USERNAME>``
   113  with your gerrit id.
   114  
   115  ::
   116  
   117      [remote "gerrit"]
   118          url = ssh://<USERNAME>@gerrit.hyperledger.org:29418/fabric.git
   119          fetch = +refs/heads/*:refs/remotes/gerrit/*
   120  
   121  Then submit your change with ``git review``.
   122  
   123  ::
   124  
   125      $ cd <your code dir>
   126      $ git review
   127  
   128  When you update your patch, you can commit with ``git commit --amend``,
   129  and then repeat the ``git review`` command.
   130  
   131  Not Use git review
   132  ~~~~~~~~~~~~~~~~~~
   133  
   134  See the :doc:`directions for building the source code <../dev-setup/build>`.
   135  
   136  When a change is ready for submission, Gerrit requires that the change
   137  be pushed to a special branch. The name of this special branch contains
   138  a reference to the final branch where the code should reside, once
   139  accepted.
   140  
   141  For the Hyperledger Fabric repository, the special branch is called
   142  ``refs/for/master``.
   143  
   144  To push the current local development branch to the gerrit server, open
   145  a terminal window at the root of your cloned repository:
   146  
   147  ::
   148  
   149      cd <your clone dir>
   150      git push origin HEAD:refs/for/master
   151  
   152  If the command executes correctly, the output should look similar to
   153  this:
   154  
   155  ::
   156  
   157      Counting objects: 3, done.
   158      Writing objects: 100% (3/3), 306 bytes | 0 bytes/s, done.
   159      Total 3 (delta 0), reused 0 (delta 0)
   160      remote: Processing changes: new: 1, refs: 1, done
   161      remote:
   162      remote: New Changes:
   163      remote:   https://gerrit.hyperledger.org/r/6 Test commit
   164      remote:
   165      To ssh://LFID@gerrit.hyperledger.org:29418/fabric
   166      * [new branch]      HEAD -> refs/for/master
   167  
   168  The gerrit server generates a link where the change can be tracked.
   169  
   170  Adding reviewers
   171  ----------------
   172  
   173  Optionally, you can add reviewers to your change.
   174  
   175  To specify a list of reviewers via the command line, add
   176  ``%r=reviewer@project.org`` to your push command. For example:
   177  
   178  ::
   179  
   180      git push origin HEAD:refs/for/master%r=rev1@email.com,r=rev2@notemail.com
   181  
   182  Alternatively, you can auto-configure GIT to add a set of reviewers if
   183  your commits will have the same reviewers all at the time.
   184  
   185  To add a list of default reviewers, open the :file:``.git/config`` file
   186  in the project directory and add the following line in the
   187  ``[ branch “master” ]`` section:
   188  
   189  ::
   190  
   191      [branch "master"] #.... push =
   192      HEAD:refs/for/master%r=rev1@email.com,r=rev2@notemail.com`
   193  
   194  Make sure to use actual email addresses instead of the
   195  ``@email.com and @notemail.com`` addressses. Don't forget to replace
   196  ``origin`` with your git remote name.
   197  
   198  Reviewing Using Gerrit
   199  ----------------------
   200  
   201  -  **Add**: This button allows the change submitter to manually add
   202     names of people who should review a change; start typing a name and
   203     the system will auto-complete based on the list of people registered
   204     and with access to the system. They will be notified by email that
   205     you are requesting their input.
   206  
   207  -  **Abandon**: This button is available to the submitter only; it
   208     allows a committer to abandon a change and remove it from the merge
   209     queue.
   210  
   211  -  **Change-ID**: This ID is generated by Gerrit (or system). It becomes
   212     useful when the review process determines that your commit(s) have to
   213     be amended. You may submit a new version; and if the same Change-ID
   214     header (and value) are present, Gerrit will remember it and present
   215     it as another version of the same change.
   216  
   217  -  **Status**: Currently, the example change is in review status, as
   218     indicated by “Needs Verified” in the upper-left corner. The list of
   219     Reviewers will all emit their opinion, voting +1 if they agree to the
   220     merge, -1 if they disagree. Gerrit users with a Maintainer role can
   221     agree to the merge or refuse it by voting +2 or -2 respectively.
   222  
   223  Notifications are sent to the email address in your commit message's
   224  Signed-off-by line. Visit your `Gerrit
   225  dashboard <https://gerrit.hyperledger.org/r/#/dashboard/self>`__, to
   226  check the progress of your requests.
   227  
   228  The history tab in Gerrit will show you the in-line comments and the
   229  author of the review.
   230  
   231  Viewing Pending Changes
   232  -----------------------
   233  
   234  Find all pending changes by clicking on the ``All --> Changes`` link in
   235  the upper-left corner, or `open this
   236  link <https://gerrit.hyperledger.org/r/#/q/project:fabric>`__.
   237  
   238  If you collaborate in multiple projects, you may wish to limit searching
   239  to the specific branch through the search bar in the upper-right side.
   240  
   241  Add the filter *project:fabric* to limit the visible changes to only
   242  those from Hyperledger Fabric.
   243  
   244  List all current changes you submitted, or list just those changes in
   245  need of your input by clicking on ``My --> Changes`` or `open this
   246  link <https://gerrit.hyperledger.org/r/#/dashboard/self>`__
   247  
   248  .. Licensed under Creative Commons Attribution 4.0 International License
   249     https://creativecommons.org/licenses/by/4.0/
   250