| 1 | _Do you have a contribution? We welcome contributions, but please ensure that you read the following information |
| 2 | before issuing a pull request. Also refer back to this document as a checklist before issuing your pull request. |
| 3 | This will save time for everyone._ |
| 4 | |
| 5 | # Before You Start |
| 6 | |
| 7 | ## Understanding the Basics |
| 8 | |
| 9 | If you don't understand what a *pull request* is, or how to submit one, please refer to the [help documentation][] |
| 10 | provided by GitHub. |
| 11 | |
| 12 | ## Is It Really a Support Issue |
| 13 | |
| 14 | If you aren't sure if your contribution is needed or necessary, please visit the [support forum][] before attempting to |
| 15 | submit a pull request or a ticket. |
| 16 | |
| 17 | ## Search Dojo Toolkit's Bug Database |
| 18 | |
| 19 | We require every commit to be tracked via our [bug database][]. It is useful, before you get too far, that you have |
| 20 | checked that your issue isn't already known, otherwise addressed? If you think it is a valid defect or enhancement, |
| 21 | please open a new ticket before submitting your pull request. |
| 22 | |
| 23 | ## Discuss Non-Trivial Contributions with the Committers |
| 24 | |
| 25 | If your desired contribution is more than a non-trivial fix, you should discuss it on the |
| 26 | [contributor's mailing list][dojo-contrib]. If you currently are not a member, you can request to be added. |
| 27 | |
| 28 | ## Contributor License Agreement |
| 29 | |
| 30 | We require all contributions, to be covered under the JS Foundation's [Contributor License Agreement][cla]. This can |
| 31 | be done electronically and essentially ensures that you are making it clear that your contributions are your |
| 32 | contributions, you have the legal right to contribute and you are transferring the copyright of your works to the JS |
| 33 | Foundation. |
| 34 | |
| 35 | If you are an unfamiliar contributor to the committer assessing your pull request, it is best to make it clear how |
| 36 | you are covered by a CLA in the notes of the pull request. A bot will verify your status. |
| 37 | |
| 38 | If your GitHub user id you are submitting your pull request from differs from the e-mail address |
| 39 | which you have signed your CLA under, you should specifically note what you have your CLA filed under. |
| 40 | |
| 41 | # Submitting a Pull Request |
| 42 | |
| 43 | The following are the general steps you should follow in creating a pull request. Subsequent pull requests only need |
| 44 | to follow step 3 and beyond: |
| 45 | |
| 46 | 1. Fork the repository on GitHub |
| 47 | 2. Clone the forked repository to your machine |
| 48 | 3. Create a "feature" branch in your local repository |
| 49 | 4. Make your changes and commit them to your local repository |
| 50 | 5. Rebase and push your commits to your GitHub remote fork/repository |
| 51 | 6. Issue a Pull Request to the official repository |
| 52 | 7. Your Pull Request is reviewed by a committer and merged into the repository |
| 53 | |
| 54 | *Note*: While there are other ways to accomplish the steps using other tools, the examples here will assume the most |
| 55 | actions will be performed via the `git` command line. |
| 56 | |
| 57 | ## 1. Fork the Repository |
| 58 | |
| 59 | When logged in to your GitHub account, and you are viewing one of the main repositories, you will see the *Fork* button. |
| 60 | Clicking this button will show you which organizations your can fork to. Choose your own account. Once the process |
| 61 | finishes, you will have your own repository that is "forked" from the official one. |
| 62 | |
| 63 | Forking is a GitHub term and not a git term. Git is a wholly distributed source control system and simply worries |
| 64 | about local and remote repositories and allows you to manage your code against them. GitHub then adds this additional |
| 65 | layer of structure of how repositories can relate to each other. |
| 66 | |
| 67 | ## 2. Clone the Forked Repository |
| 68 | |
| 69 | Once you have successfully forked your repository, you will need to clone it locally to your machine: |
| 70 | |
| 71 | ```bash |
| 72 | $ git clone --recursive [email protected]:username/themes.git |
| 73 | ``` |
| 74 | |
| 75 | This will clone your fork to your current path in a directory named `themes`. |
| 76 | |
| 77 | To test your work in this repo against Dojo, Dijit, DojoX, and dgrid, you will need to either include the relevant |
| 78 | release locally, or clone those repositories as well. |
| 79 | |
| 80 | You should also set up the `upstream` repository. This will allow you to take changes from the "master" repository |
| 81 | and merge them into your local clone and then push them to your GitHub fork: |
| 82 | |
| 83 | ```bash |
| 84 | $ cd themes |
| 85 | $ git remote add upstream [email protected]:dojo/themes.git |
| 86 | $ git fetch upstream |
| 87 | ``` |
| 88 | |
| 89 | Then you can retrieve upstream changes and rebase on them into your code like this: |
| 90 | |
| 91 | ```bash |
| 92 | $ git pull --rebase upstream master |
| 93 | ``` |
| 94 | |
| 95 | For more information on maintaining a fork, please see the GitHub Help article [Fork a Repo][] and information on |
| 96 | [rebasing][] from git. |
| 97 | |
| 98 | ## 3. Create a Branch |
| 99 | |
| 100 | The easiest workflow is to keep your master branch in sync with the upstream branch and do not locate any of your own |
| 101 | commits in that branch. When you want to work on a new feature, you then ensure you are on the master branch and create |
| 102 | a new branch from there. While the name of the branch can be anything, it can often be easy to use the ticket number |
| 103 | you might be working on. For example: |
| 104 | |
| 105 | ```bash |
| 106 | $ git checkout -b t12345 master |
| 107 | Switched to a new branch 't12345' |
| 108 | ``` |
| 109 | |
| 110 | You will then be on the feature branch. You can verify what branch you are on like this: |
| 111 | |
| 112 | ```bash |
| 113 | $ git status |
| 114 | # On branch t12345 |
| 115 | nothing to commit, working directory clean |
| 116 | ``` |
| 117 | |
| 118 | ## 4. Make Changes and Commit |
| 119 | |
| 120 | Now you just need to make your changes. Once you have finished your changes (and tested them) you need to commit them |
| 121 | to your local repository (assuming you have staged your changes for committing): |
| 122 | |
| 123 | ```bash |
| 124 | $ git status |
| 125 | # On branch t12345 |
| 126 | # Changes to be committed: |
| 127 | # (use "git reset HEAD <file>..." to unstage) |
| 128 | # |
| 129 | # modified: somefile.js |
| 130 | # |
| 131 | $ git commit -m "Corrects some defect, fixes #12345, refs #12346" |
| 132 | [t12345 0000000] Corrects some defect, fixes #12345, refs #12346 |
| 133 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 134 | ``` |
| 135 | |
| 136 | ## 5. Rebase and Push Changes |
| 137 | |
| 138 | If you have been working on your contribution for a while, the upstream repository may have changed. You may want to |
| 139 | ensure your work is on top of the latest changes so your pull request can be applied cleanly: |
| 140 | |
| 141 | ```bash |
| 142 | $ git pull --rebase upstream master |
| 143 | ``` |
| 144 | |
| 145 | When you are ready to push your commit to your GitHub repository for the first time on this branch you would do the |
| 146 | following: |
| 147 | |
| 148 | ```bash |
| 149 | $ git push -u origin t12345 |
| 150 | ``` |
| 151 | |
| 152 | After the first time, you simply need to do: |
| 153 | |
| 154 | ```bash |
| 155 | $ git push |
| 156 | ``` |
| 157 | |
| 158 | ## 6. Issue a Pull Request |
| 159 | |
| 160 | In order to have your commits merged into the main repository, you need to create a pull request. The instructions for |
| 161 | this can be found in the GitHub Help Article [Creating a Pull Request][]. Essentially you do the following: |
| 162 | |
| 163 | 1. Go to the site for your repository. |
| 164 | 2. Click the Pull Request button. |
| 165 | 3. Select the feature branch from your repository. |
| 166 | 4. Enter a title and description of your pull request mentioning the corresponding [bug database][] ticket in the description. |
| 167 | 5. Review the commit and files changed tabs. |
| 168 | 6. Click `Send Pull Request` |
| 169 | |
| 170 | You will get notified about the status of your pull request based on your GitHub settings. |
| 171 | |
| 172 | ## 7. Request is Reviewed and Merged |
| 173 | |
| 174 | Your request will be reviewed. It may be merged directly, or you may receive feedback or questions on your pull |
| 175 | request. |
| 176 | |
| 177 | # What Makes a Successful Pull Request? |
| 178 | |
| 179 | Having your contribution accepted is more than just the mechanics of getting your contribution into a pull request, |
| 180 | there are several other things that are expected when contributing to the Dojo Toolkit which are covered below. |
| 181 | |
| 182 | ## Coding Style and Linting |
| 183 | |
| 184 | Dojo has a very specific [coding style][styleguide]. All pull requests should adhere to this. |
| 185 | |
| 186 | ## Inline Documentation |
| 187 | |
| 188 | Any non-obvious style rules should include a valid CSS comment. |
| 189 | |
| 190 | ## Licensing |
| 191 | |
| 192 | All of your submissions are licensed under a dual "New" BSD/AFL license. |
| 193 | |
| 194 | ## Expect Discussion and Rework |
| 195 | |
| 196 | Unless you have been working with contributing to Dojo for a while, expect a significant amount of feedback on your |
| 197 | pull requests. We are a very passionate community and even the committers often will provide robust feedback to each |
| 198 | other about their code. Don't be offended by such feedback or feel that your contributions aren't welcome, it is just |
| 199 | that we are quite passionate and Dojo has a long history with many things that are the "Dojo-way" which may be |
| 200 | unfamiliar to those who are just starting to contribute. |
| 201 | |
| 202 | [help documentation]: http://help.github.com/send-pull-requests |
| 203 | [bug database]: http://bugs.dojotoolkit.org/ |
| 204 | [support forum]: http://dojotoolkit.org/community/ |
| 205 | [dojo-contrib]: http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors |
| 206 | [cla]: http://js.foundation/CLA |
| 207 | [Creating a Pull Request]: https://help.github.com/articles/creating-a-pull-request |
| 208 | [Fork a Repo]: https://help.github.com/articles/fork-a-repo |
| 209 | [styleguide]: http://dojotoolkit.org/reference-guide/developer/styleguide.html |
| 210 | [DojoDoc]: http://dojotoolkit.org/reference-guide/developer/markup.html |
| 211 | [dojo/util]: https://github.com/dojo/util |
| 212 | [interactive rebase]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages |
| 213 | [rebasing]: http://git-scm.com/book/en/Git-Branching-Rebasing |