1*b0d29bc4SBrooks DavisContributing code to Kyua 2*b0d29bc4SBrooks Davis========================= 3*b0d29bc4SBrooks Davis 4*b0d29bc4SBrooks DavisWant to contribute? Great! But first, please take a few minutes to read this 5*b0d29bc4SBrooks Davisdocument in full. Doing so upfront will minimize the turnaround time required 6*b0d29bc4SBrooks Davisto get your changes incorporated. 7*b0d29bc4SBrooks Davis 8*b0d29bc4SBrooks Davis 9*b0d29bc4SBrooks DavisLegal notes 10*b0d29bc4SBrooks Davis----------- 11*b0d29bc4SBrooks Davis 12*b0d29bc4SBrooks Davis* Before we can use your code, you must sign the 13*b0d29bc4SBrooks Davis [Google Individual Contributor License 14*b0d29bc4SBrooks Davis Agreement](https://developers.google.com/open-source/cla/individual), 15*b0d29bc4SBrooks Davis also known as the CLA, which you can easily do online. The CLA is necessary 16*b0d29bc4SBrooks Davis mainly because you own the copyright to your changes, even after your 17*b0d29bc4SBrooks Davis contribution becomes part of our codebase, so we need your permission to use 18*b0d29bc4SBrooks Davis and distribute your code. We also need to be sure of various other 19*b0d29bc4SBrooks Davis things--for instance that you will tell us if you know that your code 20*b0d29bc4SBrooks Davis infringes on other people's patents. You do not have to sign the CLA until 21*b0d29bc4SBrooks Davis after you have submitted your code for review and a member has approved it, 22*b0d29bc4SBrooks Davis but you must do it before we can put your code into our codebase. 23*b0d29bc4SBrooks Davis 24*b0d29bc4SBrooks Davis* Contributions made by corporations are covered by a different agreement than 25*b0d29bc4SBrooks Davis the one above: the 26*b0d29bc4SBrooks Davis [Google Software Grant and Corporate Contributor License 27*b0d29bc4SBrooks Davis Agreement](https://developers.google.com/open-source/cla/corporate). 28*b0d29bc4SBrooks Davis Please get your company to sign this agreement instead if your contribution is 29*b0d29bc4SBrooks Davis on their behalf. 30*b0d29bc4SBrooks Davis 31*b0d29bc4SBrooks Davis* Unless you have a strong reason not to, please assign copyright of your 32*b0d29bc4SBrooks Davis changes to Google Inc. and use the 3-clause BSD license text included 33*b0d29bc4SBrooks Davis throughout the codebase (see [LICENSE](LICENSE)). Keeping the whole project 34*b0d29bc4SBrooks Davis owned by a single entity is important, particularly to avoid the problem of 35*b0d29bc4SBrooks Davis having to replicate potentially hundreds of different copyright notes in 36*b0d29bc4SBrooks Davis documentation materials, etc. 37*b0d29bc4SBrooks Davis 38*b0d29bc4SBrooks Davis 39*b0d29bc4SBrooks DavisCommunication 40*b0d29bc4SBrooks Davis------------- 41*b0d29bc4SBrooks Davis 42*b0d29bc4SBrooks Davis* Before you start working on a larger contribution, you should get in touch 43*b0d29bc4SBrooks Davis with us first through the 44*b0d29bc4SBrooks Davis [kyua-discuss mailing 45*b0d29bc4SBrooks Davis list](https://groups.google.com/forum/#!forum/kyua-discuss) 46*b0d29bc4SBrooks Davis with your idea so that we can help out and possibly guide you. Coordinating 47*b0d29bc4SBrooks Davis upfront makes it much easier to avoid frustration later on. 48*b0d29bc4SBrooks Davis 49*b0d29bc4SBrooks Davis* Subscribe to the 50*b0d29bc4SBrooks Davis [kyua-log mailing list](https://groups.google.com/forum/#!forum/kyua-log) to 51*b0d29bc4SBrooks Davis get notifications on new commits, Travis CI results, or changes to bugs. 52*b0d29bc4SBrooks Davis 53*b0d29bc4SBrooks Davis 54*b0d29bc4SBrooks DavisGit workflow 55*b0d29bc4SBrooks Davis------------ 56*b0d29bc4SBrooks Davis 57*b0d29bc4SBrooks Davis* Always work on a non-master branch. 58*b0d29bc4SBrooks Davis 59*b0d29bc4SBrooks Davis* Make sure the history of your branch is clean. (Ab)use `git rebase -i master` 60*b0d29bc4SBrooks Davis to ensure the sequence of commits you want pulled is easy to follow and that 61*b0d29bc4SBrooks Davis every commit does one (and only one) thing. In particular, commits of the 62*b0d29bc4SBrooks Davis form `Fix previous` or `Fix build` should never ever exist; merge those fixes 63*b0d29bc4SBrooks Davis into the relevant commits so that the history is clean at pull time. 64*b0d29bc4SBrooks Davis 65*b0d29bc4SBrooks Davis* Always trigger Travis CI builds for your changes (hence why working on a 66*b0d29bc4SBrooks Davis branch is important). Push your branch to GitHub so that Travis CI picks it 67*b0d29bc4SBrooks Davis up and performs a build. If you have forked the repository, you may need to 68*b0d29bc4SBrooks Davis enable Travis CI builds on your end. Wait for a green result. 69*b0d29bc4SBrooks Davis 70*b0d29bc4SBrooks Davis* It is OK and expected for you to `git push --force` on **non-master** 71*b0d29bc4SBrooks Davis branches. This is required if you need to go through the commit/test cycle 72*b0d29bc4SBrooks Davis more than once for any given branch after you have "fixed-up" commits to 73*b0d29bc4SBrooks Davis correct problems spotted in earlier builds. 74*b0d29bc4SBrooks Davis 75*b0d29bc4SBrooks Davis* Do not send pull requests that subsume other/older pull requests. Each major 76*b0d29bc4SBrooks Davis change being submitted belongs in a different pull request, which is trivial 77*b0d29bc4SBrooks Davis to achieve if you use one branch per change as requested in this workflow. 78*b0d29bc4SBrooks Davis 79*b0d29bc4SBrooks Davis 80*b0d29bc4SBrooks DavisCode reviews 81*b0d29bc4SBrooks Davis------------ 82*b0d29bc4SBrooks Davis 83*b0d29bc4SBrooks Davis* All changes will be subject to code reviews pre-merge time. In other words: 84*b0d29bc4SBrooks Davis all pull requests will be carefully inspected before being accepted and they 85*b0d29bc4SBrooks Davis will be returned to you with comments if there are issues to be fixed. 86*b0d29bc4SBrooks Davis 87*b0d29bc4SBrooks Davis* Be careful of stylistic errors in your code (see below for style guidelines). 88*b0d29bc4SBrooks Davis Style violations hinder the review process and distract from the actual code. 89*b0d29bc4SBrooks Davis By keeping your code clean of style issues upfront, you will speed up the 90*b0d29bc4SBrooks Davis review process and avoid frustration along the way. 91*b0d29bc4SBrooks Davis 92*b0d29bc4SBrooks Davis* Whenever you are ready to submit a pull request, review the *combined diff* 93*b0d29bc4SBrooks Davis you are requesting to be pulled and look for issues. This is the diff that 94*b0d29bc4SBrooks Davis will be subject to review, not necessarily the individual commits. You can 95*b0d29bc4SBrooks Davis view this diff in GitHub at the bottom of the `Open a pull request` form that 96*b0d29bc4SBrooks Davis appears when you click the button to file a pull request, or you can see the 97*b0d29bc4SBrooks Davis diff by typing `git diff <your-branch> master`. 98*b0d29bc4SBrooks Davis 99*b0d29bc4SBrooks Davis 100*b0d29bc4SBrooks DavisCommit messages 101*b0d29bc4SBrooks Davis--------------- 102*b0d29bc4SBrooks Davis 103*b0d29bc4SBrooks Davis* Follow standard Git commit message guidelines. The first line has a maximum 104*b0d29bc4SBrooks Davis length of 50 characters, does not terminate in a period, and has to summarize 105*b0d29bc4SBrooks Davis the whole commit. Then a blank line comes, and then multiple plain-text 106*b0d29bc4SBrooks Davis paragraphs provide details on the commit if necessary with a maximum length of 107*b0d29bc4SBrooks Davis 72-75 characters per line. Vim has syntax highlighting for Git commit 108*b0d29bc4SBrooks Davis messages and will let you know when you go above the maximum line lengths. 109*b0d29bc4SBrooks Davis 110*b0d29bc4SBrooks Davis* Use the imperative tense. Say `Add foo-bar` or `Fix baz` instead of `Adding 111*b0d29bc4SBrooks Davis blah`, `Adds bleh`, or `Added bloh`. 112*b0d29bc4SBrooks Davis 113*b0d29bc4SBrooks Davis 114*b0d29bc4SBrooks DavisHandling bug tracker issues 115*b0d29bc4SBrooks Davis--------------------------- 116*b0d29bc4SBrooks Davis 117*b0d29bc4SBrooks Davis* All changes pushed to `master` should cross-reference one or more issues in 118*b0d29bc4SBrooks Davis the bug tracker. This is particularly important for bug fixes, but also 119*b0d29bc4SBrooks Davis applies to major feature improvements. 120*b0d29bc4SBrooks Davis 121*b0d29bc4SBrooks Davis* Unless you have a good reason to do otherwise, name your branch `issue-N` 122*b0d29bc4SBrooks Davis where `N` is the number of the issue being fixed. 123*b0d29bc4SBrooks Davis 124*b0d29bc4SBrooks Davis* If the fix to the issue can be done *in a single commit*, terminate the commit 125*b0d29bc4SBrooks Davis message with `Fixes #N.` where `N` is the number of the issue being fixed and 126*b0d29bc4SBrooks Davis include a note in `NEWS` about the issue in the same commit. Such fixes can 127*b0d29bc4SBrooks Davis be merged onto master using fast-forward (the default behavior of `git 128*b0d29bc4SBrooks Davis merge`). 129*b0d29bc4SBrooks Davis 130*b0d29bc4SBrooks Davis* If the fix to the issue requires *more than one commit*, do **not** include 131*b0d29bc4SBrooks Davis `Fixes #N.` in any of the individual commit messages of the branch nor include 132*b0d29bc4SBrooks Davis any changes to the `NEWS` file in those commits. These "announcement" changes 133*b0d29bc4SBrooks Davis belong in the merge commit onto `master`, which is done by `git merge --no-ff 134*b0d29bc4SBrooks Davis --no-commit your-branch`, followed by an edit of `NEWS`, and terminated with a 135*b0d29bc4SBrooks Davis `git commit -a` with the proper note on the bug being fixed. 136*b0d29bc4SBrooks Davis 137*b0d29bc4SBrooks Davis 138*b0d29bc4SBrooks DavisStyle guide 139*b0d29bc4SBrooks Davis----------- 140*b0d29bc4SBrooks Davis 141*b0d29bc4SBrooks DavisThese notes are generic and certainly *non-exhaustive*: 142*b0d29bc4SBrooks Davis 143*b0d29bc4SBrooks Davis* Respect formatting of existing files. Note where braces are placed, number of 144*b0d29bc4SBrooks Davis blank lines between code chunks, how continuation lines are indented, how 145*b0d29bc4SBrooks Davis docstrings are typed, etc. 146*b0d29bc4SBrooks Davis 147*b0d29bc4SBrooks Davis* Indentation is *always* done using spaces, not tabs. The only exception is in 148*b0d29bc4SBrooks Davis `Makefile`s, where any continuation line within a target must be prefixed by a 149*b0d29bc4SBrooks Davis *single tab*. 150*b0d29bc4SBrooks Davis 151*b0d29bc4SBrooks Davis* [Be mindful of spelling and 152*b0d29bc4SBrooks Davis grammar.](http://julipedia.meroh.net/2013/06/readability-mind-your-typos-and-grammar.html) 153*b0d29bc4SBrooks Davis Mistakes of this kind are enough of a reason to return a pull request. 154*b0d29bc4SBrooks Davis 155*b0d29bc4SBrooks Davis* Use proper punctuation for all sentences. Always start with a capital letter 156*b0d29bc4SBrooks Davis and terminate with a period. 157*b0d29bc4SBrooks Davis 158*b0d29bc4SBrooks Davis* Respect lexicographical sorting wherever possible. 159*b0d29bc4SBrooks Davis 160*b0d29bc4SBrooks Davis* Lines must not be over 80 characters. 161*b0d29bc4SBrooks Davis 162*b0d29bc4SBrooks Davis* No trailing whitespace. 163*b0d29bc4SBrooks Davis 164*b0d29bc4SBrooks Davis* Two spaces after end-of-sentence periods. 165*b0d29bc4SBrooks Davis 166*b0d29bc4SBrooks Davis* Two blank lines between functions. If there are two blank lines among code 167*b0d29bc4SBrooks Davis blocks, they usually exist for a reason: keep them. 168*b0d29bc4SBrooks Davis 169*b0d29bc4SBrooks Davis* In C++ code, prefix all C identifiers (those coming from `extern "C"` 170*b0d29bc4SBrooks Davis includes) with `::`. 171*b0d29bc4SBrooks Davis 172*b0d29bc4SBrooks Davis* Getter functions/methods only need to be documented via `\return`. A 173*b0d29bc4SBrooks Davis redundant summary is not necessary. 174