github.com/jaegerpicker/docker@v0.7.7-0.20150325003727-22dba32b4dab/docs/sources/project/work-issue.md (about)

     1  page_title: Work on your issue
     2  page_description: Basic workflow for Docker contributions
     3  page_keywords: contribute, pull request, review, workflow, beginner, squash, commit
     4  
     5  
     6  # Work on your issue
     7  
     8  The work you do for your issue depends on the specific issue you picked.
     9  This section gives you a step-by-step workflow. Where appropriate, it provides
    10  command examples. 
    11  
    12  However, this is a generalized workflow, depending on your issue you may repeat
    13  steps or even skip some. How much time the work takes depends on you --- you
    14  could spend days or 30 minutes of your time.
    15  
    16  ## How to work on your local branch
    17  
    18  Follow this workflow as you work:
    19  
    20  1. Review the appropriate style guide.
    21  
    22      If you are changing code, review the <a href="../coding-style"
    23      target="_blank">coding style guide</a>. Changing documentation? Review the
    24      <a href="../doc-style" target="_blank">documentation style guide</a>. 
    25  	
    26  2. Make changes in your feature branch.
    27  
    28      Your feature branch you created in the last section. Here you use the
    29      development container. If you are making a code change, you can mount your
    30      source into a development container and iterate that way. For documentation
    31      alone, you can work on your local host. 
    32  
    33      Make sure you don't change files in the `vendor` directory and its
    34      subdirectories; they contain third-party dependency code. Review <a
    35      href="../set-up-dev-env" target="_blank">if you forgot the details of
    36      working with a container</a>.
    37  
    38  
    39  3. Test your changes as you work.
    40  
    41      If you have followed along with the guide, you know the `make test` target
    42      runs the entire test suite and `make docs` builds the documentation. If you
    43      forgot the other test targets, see the documentation for <a
    44      href="../test-and-docs" target="_blank">testing both code and
    45      documentation</a>.  
    46  	
    47  4. For code changes, add unit tests if appropriate.
    48  
    49      If you add new functionality or change existing functionality, you should
    50      add a unit test also. Use the existing test files for inspiration. Aren't
    51      sure if you need tests? Skip this step; you can add them later in the
    52      process if necessary.
    53  	
    54  5. Format your source files correctly.
    55  
    56      <table>
    57        <thead>
    58        <tr>
    59          <th>File type</th>
    60          <th>How to format</th>
    61        </tr>
    62        </thead>
    63        <tbody>
    64        <tr>
    65          <td><code>.go</code></td>
    66          <td>
    67              <p>
    68              Format <code>.go</code> files using the <code>gofmt</code> command.
    69              For example, if you edited the `docker.go` file you would format the file
    70              like this:
    71              </p>
    72              <p><code>$ gofmt -s -w file.go</code></p>
    73              <p>
    74              Most file editors have a plugin to format for you. Check your editor's
    75              documentation.
    76              </p>
    77          </td>
    78        </tr>
    79        <tr>
    80          <td style="white-space: nowrap"><code>.md</code> and non-<code>.go</code> files</td>
    81          <td>Wrap lines to 80 characters.</td>
    82        </tr>
    83        </tbody>
    84      </table>
    85  
    86  6. List your changes.
    87  
    88          $ git status
    89          On branch 11038-fix-rhel-link
    90          Changes not staged for commit:
    91            (use "git add <file>..." to update what will be committed)
    92            (use "git checkout -- <file>..." to discard changes in working directory)
    93  
    94          modified:   docs/sources/installation/mac.md
    95          modified:   docs/sources/installation/rhel.md
    96  
    97      The `status` command lists what changed in the repository. Make sure you see
    98      the changes you expect.
    99  
   100  7. Add your change to Git.
   101  
   102          $ git add docs/sources/installation/mac.md
   103          $ git add docs/sources/installation/rhel.md
   104  
   105  
   106  8. Commit your changes making sure you use the `-s` flag to sign your work.
   107  
   108          $ git commit -s -m "Fixing RHEL link"
   109  
   110  9. Push your change to your repository.
   111  
   112          $ git push origin
   113          Username for 'https://github.com': moxiegirl
   114          Password for 'https://moxiegirl@github.com': 
   115          Counting objects: 60, done.
   116          Compressing objects: 100% (7/7), done.
   117          Writing objects: 100% (7/7), 582 bytes | 0 bytes/s, done.
   118          Total 7 (delta 6), reused 0 (delta 0)
   119          To https://github.com/moxiegirl/docker.git
   120           * [new branch]      11038-fix-rhel-link -> 11038-fix-rhel-link
   121          Branch 11038-fix-rhel-link set up to track remote branch 11038-fix-rhel-link from origin.
   122          
   123      The first time you push a change, you must specify the branch. Later, you can just do this:
   124      
   125      	git push origin
   126      	
   127  ## Review your branch on GitHub
   128  
   129  After you push a new branch, you should verify it on GitHub:
   130  
   131  1. Open your browser to <a href="https://github.com" target="_blank">GitHub</a>.
   132  
   133  2. Go to your Docker fork.
   134  
   135  3. Select your branch from the dropdown.
   136  
   137  	![Find branch](/project/images/locate_branch.png)
   138  	
   139  4. Use the "Compare" button to compare the differences between your branch and master.
   140  
   141  	 Depending how long you've been working on your branch, your branch maybe
   142  	 behind Docker's upstream repository. 
   143  	 
   144  5. Review the commits.
   145  
   146  	 Make sure your branch only shows the work you've done.
   147  	 
   148  ## Pull and rebase frequently
   149  
   150  You should pull and rebase frequently as you work.  
   151  
   152  1. Return to the terminal on your local machine.
   153  
   154  2. Make sure you are in your branch.
   155  
   156  		$ git branch 11038-fix-rhel-link
   157  
   158  3. Fetch all the changes from the `upstream/master` branch.
   159  
   160  		 $ git fetch upstream/master
   161  
   162    	This command says get all the changes from the `master` branch belonging to
   163    	the `upstream` remote.
   164  
   165  4. Rebase your local master with Docker's `upstream/master` branch.
   166  
   167  		 $ git rebase -i upstream/master
   168     
   169    	This command starts an interactive rebase to merge code from Docker's
   170    	`upstream/master` branch into your local branch. If you aren't familiar or
   171    	comfortable with rebase, you can <a
   172    	href="http://nathanleclaire.com/blog/2014/09/14/dont-be-scared-of-git-
   173    	rebase" target="_blank">learn more about rebasing</a> on the web.
   174    
   175  5. Rebase opens an editor with a list of commits.
   176  
   177  			pick 1a79f55 Tweak some of the other text for grammar 
   178  			pick 53e4983 Fix a link 
   179  			pick 3ce07bb Add a new line about RHEL
   180          
   181    	If you run into trouble, `git --rebase abort` removes any changes and gets
   182    	you back to where you started. 
   183  
   184  6. Squash the `pick` keyword with `squash` on all but the first commit.
   185  
   186  			pick 1a79f55 Tweak some of the other text for grammar
   187  			squash 53e4983 Fix a link
   188  			squash 3ce07bb Add a new line about RHEL
   189  
   190    	After closing the file, `git` opens your editor again to edit the commit
   191    	message. 
   192  
   193  7. Edit and save your commit message.
   194  
   195  	Make sure you include your signature.
   196  
   197  8. Push any changes to your fork on GitHub.
   198  
   199  		$ git push origin 11038-fix-rhel-link
   200  
   201  
   202  ## Where to go next
   203  
   204  At this point, you should understand how to work on an issue. In the next
   205  section, you [learn how to make a pull request](/project/create-pr/).