|
| 1 | +# Contributing to C2MON |
| 2 | + |
| 3 | +Have something you'd like to contribute to the framework? We welcome pull |
| 4 | +requests but ask that you carefully read this document first to understand how |
| 5 | +best to submit them; what kind of changes are likely to be accepted; and what |
| 6 | +to expect from the C2MON team when evaluating your submission. |
| 7 | + |
| 8 | +_Please refer back to this document as a checklist before issuing any pull |
| 9 | +request; this will save time for everyone!_ |
| 10 | + |
| 11 | +## Take Your First Steps |
| 12 | + |
| 13 | +### Understand the basics |
| 14 | + |
| 15 | +Not sure what a pull request is, or how to submit one? Take a look at GitHub's |
| 16 | +excellent [help documentation][] first. |
| 17 | + |
| 18 | +### Search issues; create an issue if necessary |
| 19 | + |
| 20 | +Is there already an issue that addresses your concern? Do a bit of searching |
| 21 | +in our [issue tracker][] to see if |
| 22 | +you can find something similar. If you do not find something similar, please |
| 23 | +create a new issue before submitting a pull request unless the change is truly |
| 24 | +trivial -- for example: typo fixes, removing compiler warnings, etc. |
| 25 | + |
| 26 | +## Fork and clone the repository |
| 27 | + |
| 28 | +You will need to fork the main C2MON repository and clone it to your local machine. See |
| 29 | +[github help page](https://help.github.com/articles/fork-a-repo) for help. |
| 30 | + |
| 31 | +## Create a Branch |
| 32 | + |
| 33 | +### Branch from `master` |
| 34 | + |
| 35 | +Please submit all pull requests to master, even bug fixes and minor improvements. |
| 36 | + |
| 37 | +### Use short branch names |
| 38 | + |
| 39 | +Branches used when submitting pull requests should preferably be named using |
| 40 | +succinct, lower-case, dash (-) delimited names, such as 'fix-warnings', |
| 41 | +'fix-typo', etc. Otherwise, name the branch according to the issue number, |
| 42 | +e.g. 'issue-123'. |
| 43 | + |
| 44 | + |
| 45 | +## Use the C2MON code style |
| 46 | + |
| 47 | +Please read the [C2MON code style guide][] for full details, but for the |
| 48 | +meantime, here's a quick summary: |
| 49 | + |
| 50 | +### Mind the whitespace |
| 51 | + |
| 52 | +Please carefully follow the whitespace and formatting conventions already |
| 53 | +present in the framework. |
| 54 | + |
| 55 | +1. Two spaces, no tabs |
| 56 | +1. Unix (LF), not DOS (CRLF) line endings |
| 57 | +1. Eliminate all trailing whitespace |
| 58 | +1. Wrap Javadoc at 80 characters |
| 59 | +1. Aim to wrap code at 120 characters, but favour readability over wrapping |
| 60 | +1. Preserve existing formatting; i.e. do not reformat code for its own sake |
| 61 | +1. Search the codebase using `git grep` and other tools to discover common |
| 62 | + naming conventions, etc. |
| 63 | +1. Latin-1 (ISO-8859-1) encoding for Java sources; use `native2ascii` to convert |
| 64 | + if necessary |
| 65 | + |
| 66 | + |
| 67 | +### Add LGPLv3 license header to all new classes |
| 68 | + |
| 69 | +```java |
| 70 | +/****************************************************************************** |
| 71 | + * Copyright (C) 2010-2016 CERN. All rights not expressly granted are reserved. |
| 72 | + * |
| 73 | + * This file is part of the CERN Control and Monitoring Platform 'C2MON'. |
| 74 | + * C2MON is free software: you can redistribute it and/or modify it under the |
| 75 | + * terms of the GNU Lesser General Public License as published by the Free |
| 76 | + * Software Foundation, either version 3 of the license. |
| 77 | + * |
| 78 | + * C2MON is distributed in the hope that it will be useful, but WITHOUT ANY |
| 79 | + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 80 | + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| 81 | + * more details. |
| 82 | + * |
| 83 | + * You should have received a copy of the GNU Lesser General Public License |
| 84 | + * along with C2MON. If not, see <http://www.gnu.org/licenses/>. |
| 85 | + *****************************************************************************/ |
| 86 | + |
| 87 | +package ...; |
| 88 | +``` |
| 89 | + |
| 90 | +### Update LGPLv3 license header in modified files as necessary |
| 91 | + |
| 92 | +Always check the date range in the license header. For example, if you've |
| 93 | +modified a file in 2016 whose header still reads: |
| 94 | + |
| 95 | +```java |
| 96 | +/* |
| 97 | + * Copyright (C) 2010-2015 CERN. All rights not expressly granted are reserved. |
| 98 | +``` |
| 99 | +
|
| 100 | +Then be sure to update it to 2016 accordingly: |
| 101 | +
|
| 102 | +```java |
| 103 | +/* |
| 104 | + * Copyright (C) 2010-2016 CERN. All rights not expressly granted are reserved. |
| 105 | +``` |
| 106 | +
|
| 107 | +## Prepare Your Commit |
| 108 | +
|
| 109 | +### Submit JUnit test cases for all behaviour changes |
| 110 | +
|
| 111 | +Search the codebase to find related tests and add additional `@Test` methods |
| 112 | +as appropriate. |
| 113 | +
|
| 114 | +### Use real name in git commits |
| 115 | +
|
| 116 | +Please configure git to use your real first and last name for any commits you |
| 117 | +intend to submit as pull requests. For example, this is not acceptable: |
| 118 | +
|
| 119 | + Author: Nickname <user@mail.com> |
| 120 | +
|
| 121 | +Rather, please include your first and last name, properly capitalized: |
| 122 | +
|
| 123 | + Author: First Last <user@mail.com> |
| 124 | +
|
| 125 | +This helps ensure traceability and also goes a long way to |
| 126 | +ensuring useful output from tools like `git shortlog` and others. |
| 127 | +
|
| 128 | +You can configure this via the account admin area in GitHub (useful for |
| 129 | +fork-and-edit cases); _globally_ on your machine with |
| 130 | +
|
| 131 | + git config --global user.name "First Last" |
| 132 | + git config --global user.email user@mail.com |
| 133 | +
|
| 134 | +or _locally_ for the `c2mon` repository only by omitting the |
| 135 | +'--global' flag: |
| 136 | +
|
| 137 | + cd c2mon |
| 138 | + git config user.name "First Last" |
| 139 | + git config user.email user@mail.com |
| 140 | +
|
| 141 | +
|
| 142 | +### Format commit messages |
| 143 | +
|
| 144 | +Please read and follow the [Commit Guidelines section of Pro Git][]. |
| 145 | +
|
| 146 | +Most importantly, please format your commit messages in the following way |
| 147 | +(adapted from the commit template in the link above): |
| 148 | +
|
| 149 | + #25: Short (50 chars or less) summary of changes |
| 150 | +
|
| 151 | + More detailed explanatory text, if necessary. Wrap it to about 72 |
| 152 | + characters or so. In some contexts, the first line is treated as the |
| 153 | + subject of an email and the rest of the text as the body. The blank |
| 154 | + line separating the summary from the body is critical (unless you omit |
| 155 | + the body entirely); tools like rebase can get confused if you run the |
| 156 | + two together. |
| 157 | +
|
| 158 | + Further paragraphs come after blank lines. |
| 159 | +
|
| 160 | + - Bullet points are okay, too |
| 161 | +
|
| 162 | + - Typically a hyphen or asterisk is used for the bullet, preceded by a |
| 163 | + single space, with blank lines in between, but conventions vary here |
| 164 | +
|
| 165 | +
|
| 166 | +1. Prefix the subject line with the a hash symbol, followed by the related |
| 167 | + issue number, followed by a colon and a space, e.g. "#25: Fix ...". |
| 168 | +1. Use imperative statements in the subject line, e.g. "Fix broken Javadoc link". |
| 169 | +1. Begin the subject line with a capitalized verb, e.g. "Add, Prune, Fix, |
| 170 | + Introduce, Avoid" etc. |
| 171 | +1. Do not end the subject line with a period. |
| 172 | +1. Restrict the subject line to 50 characters or less if possible. |
| 173 | +1. Wrap lines in the body at 72 characters or less. |
| 174 | +1. Mention associated issue(s) at the end of the commit comment, prefixed |
| 175 | + with "Issue: " as above. |
| 176 | +1. In the body of the commit message, explain how things worked before this |
| 177 | + commit, what has changed, and how things work now. |
| 178 | +1. _Check your spelling!_ |
| 179 | +
|
| 180 | +## Run the Final Checklist |
| 181 | +
|
| 182 | +### Run all tests prior to submission |
| 183 | +
|
| 184 | +See the [building from source][] section of the `README` for instructions. Make |
| 185 | +sure that all tests pass prior to submitting your pull request. |
| 186 | +
|
| 187 | +
|
| 188 | +### Submit your pull request |
| 189 | +
|
| 190 | +Subject line: |
| 191 | +
|
| 192 | +Follow the same conventions for pull request subject lines as mentioned above |
| 193 | +for commit message subject lines. |
| 194 | +
|
| 195 | +In the body: |
| 196 | +
|
| 197 | +1. Explain your use case. What led you to submit this change? Why were existing |
| 198 | + mechanisms in the framework insufficient? Make a case that this is a |
| 199 | + general-purpose problem and that yours is a general-purpose solution, etc. |
| 200 | +1. Add any additional information and ask questions; start a conversation or |
| 201 | + continue one from an issue. |
| 202 | +1. Mention the issue ID. |
| 203 | +
|
| 204 | +Note that for pull requests containing a single commit, the subject line and |
| 205 | +body of the pull request will be defaulted to match the subject line and body of |
| 206 | +the commit message. This is fine, but please also include the items above in the |
| 207 | +body of the request. |
| 208 | +
|
| 209 | +
|
| 210 | +### Mention your pull request on the associated issue |
| 211 | +
|
| 212 | +Add a comment to the associated issue(s) linking to your new pull request. |
| 213 | +
|
| 214 | +
|
| 215 | +### Expect discussion and rework |
| 216 | +
|
| 217 | +The C2MON team takes a very conservative approach to accepting contributions to |
| 218 | +the framework. This is to keep code quality and stability as high as possible, |
| 219 | +and to keep complexity at a minimum. Your changes, if accepted, may be heavily |
| 220 | +modified prior to merging. You will retain "Author:" attribution for your Git |
| 221 | +commits granted that the bulk of your changes remain intact. You may be asked to |
| 222 | +rework the submission for style (as explained above) and/or substance. Again, we |
| 223 | +strongly recommend discussing any serious submissions with the C2MON |
| 224 | +team _prior_ to engaging in serious development work. |
| 225 | +
|
| 226 | +Note that you can always force push (`git push -f`) reworked / rebased commits |
| 227 | +against the branch used to submit your pull request. In other words, you do not |
| 228 | +need to issue a new pull request when asked to make changes. |
| 229 | +
|
| 230 | +[help documentation]: http://help.github.com/send-pull-requests |
| 231 | +[issue tracker]: https://gitlab.cern.ch/c2mon/c2mon/issues |
| 232 | +[C2MON Code Style]: https://gitlab.cern.ch/c2mon/c2mon/blob/master/CODESTYLE.md |
| 233 | +[Rewriting History section of Pro Git]: http://git-scm.com/book/en/Git-Tools-Rewriting-History |
| 234 | +[Commit Guidelines section of Pro Git]: http://git-scm.com/book/en/Distributed-Git-Contributing-to-a-Project#Commit-Guidelines |
| 235 | +[building from source]: https://gitlab.cern.ch/c2mon/c2mon#building-from-source |
0 commit comments