|
| 1 | +# Contributing to Trime |
| 2 | + |
| 3 | +We would love for you to contribute to Trime and help make it even better than it is today! |
| 4 | +As a contributor, here are the guidelines we would like you to follow: |
| 5 | + |
| 6 | + - [Code of Conduct](#coc) |
| 7 | + - [Question or Problem?](#question) |
| 8 | + - [Issues and Bugs](#issue) |
| 9 | + - [Feature Requests](#feature) |
| 10 | + - [Submission Guidelines](#submit) |
| 11 | + - [Coding Rules](#rules) |
| 12 | + - [Commit Message Guidelines](#commit) |
| 13 | + |
| 14 | + |
| 15 | +## <a name="coc"></a> Code of Conduct |
| 16 | + |
| 17 | +Help us keep Trime open and inclusive. |
| 18 | +Please read and follow our [Code of Conduct][coc]. |
| 19 | + |
| 20 | + |
| 21 | +## <a name="question"></a> Got a Question or Problem? |
| 22 | + |
| 23 | +Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests. |
| 24 | +Instead, we recommend using QQ or Tieba. |
| 25 | + |
| 26 | +To save your and our time, we will systematically close all issues that are requests for general support and redirect people to community. |
| 27 | + |
| 28 | +## <a name="issue"></a> Found a Bug? |
| 29 | + |
| 30 | +If you find a bug in the source code, you can help us by [submitting an issue](#submit-issue) to our [GitHub Repository][github]. |
| 31 | +Even better, you can [submit a Pull Request](#submit-pr) with a fix. |
| 32 | + |
| 33 | + |
| 34 | +## <a name="feature"></a> Missing a Feature? |
| 35 | +You can *request* a new feature by [submitting an issue](#submit-issue) to our GitHub Repository. |
| 36 | +If you would like to *implement* a new feature, please consider the size of the change in order to determine the right steps to proceed: |
| 37 | + |
| 38 | +* For a **Major Feature**, first open an issue and outline your proposal so that it can be discussed. |
| 39 | + This process allows us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project. |
| 40 | + |
| 41 | + **Note**: Adding a new topic to the documentation, or significantly re-writing a topic, counts as a major feature. |
| 42 | + |
| 43 | +* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr). |
| 44 | + |
| 45 | + |
| 46 | +## <a name="submit"></a> Submission Guidelines |
| 47 | + |
| 48 | + |
| 49 | +### <a name="submit-issue"></a> Submitting an Issue |
| 50 | + |
| 51 | +Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available. |
| 52 | + |
| 53 | +We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. |
| 54 | +In order to reproduce bugs, we require that you provide a minimal reproduction. |
| 55 | +Having a minimal reproducible scenario gives us a wealth of important information without going back and forth to you with additional questions. |
| 56 | + |
| 57 | +A minimal reproduction allows us to quickly confirm a bug (or point out a coding problem) as well as confirm that we are fixing the right problem. |
| 58 | + |
| 59 | +We require a minimal reproduction to save maintainers' time and ultimately be able to fix more bugs. |
| 60 | +Often, developers find coding problems themselves while preparing a minimal reproduction. |
| 61 | +We understand that sometimes it might be hard to extract essential bits of code from a larger codebase but we really need to isolate the problem before we can fix it. |
| 62 | + |
| 63 | +Unfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you, we are going to close an issue that doesn't have enough info to be reproduced. |
| 64 | + |
| 65 | +You can file new issues by selecting from our [new issue templates](https://github.com/osfans/trime/issues/new/choose) and filling out the issue template. |
| 66 | + |
| 67 | + |
| 68 | +### <a name="submit-pr"></a> Submitting a Pull Request (PR) |
| 69 | + |
| 70 | +Before you submit your Pull Request (PR) consider the following guidelines: |
| 71 | + |
| 72 | +1. Search [GitHub](https://github.com/osfans/trime/pulls) for an open or closed PR that relates to your submission. |
| 73 | + You don't want to duplicate existing efforts. |
| 74 | + |
| 75 | +2. Be sure that an issue describes the problem you're fixing, or documents the design for the feature you'd like to add. |
| 76 | + Discussing the design upfront helps to ensure that we're ready to accept your work. |
| 77 | + |
| 78 | +3. [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) the osfans/trime repo. |
| 79 | + |
| 80 | +4. In your forked repository, make your changes in a new git branch: |
| 81 | + |
| 82 | + ```shell |
| 83 | + git checkout -b my-fix-branch master |
| 84 | + ``` |
| 85 | + |
| 86 | +5. Create your patch, **including appropriate test cases**. |
| 87 | + |
| 88 | +6. Follow our [Coding Rules](#rules). |
| 89 | + |
| 90 | +7. Run the full test suite, and ensure that all tests pass. |
| 91 | + |
| 92 | +8. Commit your changes using a descriptive commit message that follows our [commit message conventions](#commit). |
| 93 | + Adherence to these conventions is necessary because release notes are automatically generated from these messages. |
| 94 | + |
| 95 | + ```shell |
| 96 | + git commit --all |
| 97 | + ``` |
| 98 | + Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. |
| 99 | + |
| 100 | +9. Push your branch to GitHub: |
| 101 | + |
| 102 | + ```shell |
| 103 | + git push origin my-fix-branch |
| 104 | + ``` |
| 105 | + |
| 106 | +10. In GitHub, send a pull request to `trime:develop`. |
| 107 | + |
| 108 | +### Reviewing a Pull Request |
| 109 | + |
| 110 | +The Trime team reserves the right not to accept pull requests from community members who haven't been good citizens of the community. Such behavior includes not following the [Trime code of conduct][coc] and applies within or outside of Trime managed channels. |
| 111 | +
|
| 112 | +#### Addressing review feedback |
| 113 | +
|
| 114 | +If we ask for changes via code reviews then: |
| 115 | +
|
| 116 | +1. Make the required updates to the code. |
| 117 | +
|
| 118 | +2. Re-run the Trime test suites to ensure tests are still passing. |
| 119 | +
|
| 120 | +3. Create a fixup commit and push to your GitHub repository (this will update your Pull Request): |
| 121 | +
|
| 122 | + ```shell |
| 123 | + git commit --all --fixup HEAD |
| 124 | + git push |
| 125 | + ``` |
| 126 | +
|
| 127 | +That's it! Thank you for your contribution! |
| 128 | + |
| 129 | + |
| 130 | +##### Updating the commit message |
| 131 | + |
| 132 | +A reviewer might often suggest changes to a commit message (for example, to add more context for a change or adhere to our [commit message guidelines](#commit)). |
| 133 | +In order to update the commit message of the last commit on your branch: |
| 134 | + |
| 135 | +1. Check out your branch: |
| 136 | + |
| 137 | + ```shell |
| 138 | + git checkout my-fix-branch |
| 139 | + ``` |
| 140 | + |
| 141 | +2. Amend the last commit and modify the commit message: |
| 142 | + |
| 143 | + ```shell |
| 144 | + git commit --amend |
| 145 | + ``` |
| 146 | + |
| 147 | +3. Push to your GitHub repository: |
| 148 | + |
| 149 | + ```shell |
| 150 | + git push --force-with-lease |
| 151 | + ``` |
| 152 | + |
| 153 | +> NOTE:<br /> |
| 154 | +> If you need to update the commit message of an earlier commit, you can use `git rebase` in interactive mode. |
| 155 | +> See the [git docs](https://git-scm.com/docs/git-rebase#_interactive_mode) for more details. |
| 156 | + |
| 157 | + |
| 158 | +#### After your pull request is merged |
| 159 | + |
| 160 | +After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository: |
| 161 | + |
| 162 | +* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows: |
| 163 | + |
| 164 | + ```shell |
| 165 | + git push origin --delete my-fix-branch |
| 166 | + ``` |
| 167 | + |
| 168 | +* Check out the master branch: |
| 169 | + |
| 170 | + ```shell |
| 171 | + git checkout master -f |
| 172 | + ``` |
| 173 | + |
| 174 | +* Delete the local branch: |
| 175 | + |
| 176 | + ```shell |
| 177 | + git branch -D my-fix-branch |
| 178 | + ``` |
| 179 | + |
| 180 | +* Update your master with the latest upstream version: |
| 181 | + |
| 182 | + ```shell |
| 183 | + git pull --ff upstream master |
| 184 | + ``` |
| 185 | + |
| 186 | + |
| 187 | +## <a name="rules"></a> Coding Rules |
| 188 | +To ensure consistency throughout the source code, keep these rules in mind as you are working: |
| 189 | + |
| 190 | +* All features or bug fixes **must be tested** by one or more specs (unit-tests). |
| 191 | +* All public API methods **must be documented**. |
| 192 | +* We follow [Google's Java Style Guide](https://github.com/google/google-java-format]). |
| 193 | +
|
| 194 | + An automated formatter is available, see [spotless](https://github.com/diffplug/spotless). |
| 195 | +
|
| 196 | +
|
| 197 | +## <a name="commit"></a> Commit Message Format |
| 198 | +
|
| 199 | +*This specification is inspired by and supersedes the [AngularJS commit message format][commit-message-format].* |
| 200 | +
|
| 201 | +We have very precise rules over how our Git commit messages must be formatted. |
| 202 | +This format leads to **easier to read commit history**. |
| 203 | +
|
| 204 | +Each commit message consists of a **header**, a **body**, and a **footer**. |
| 205 | +
|
| 206 | +
|
| 207 | +``` |
| 208 | +<header> |
| 209 | +<BLANK LINE> |
| 210 | +<body> |
| 211 | +<BLANK LINE> |
| 212 | +<footer> |
| 213 | +``` |
| 214 | +
|
| 215 | +The `header` is mandatory and must conform to the [Commit Message Header](#commit-header) format. |
| 216 | +
|
| 217 | +The `body` is mandatory for all commits except for those of type "docs". |
| 218 | +When the body is present it must be at least 20 characters long and must conform to the [Commit Message Body](#commit-body) format. |
| 219 | +
|
| 220 | +The `footer` is optional. The [Commit Message Footer](#commit-footer) format describes what the footer is used for and the structure it must have. |
| 221 | +
|
| 222 | +Any line of the commit message cannot be longer than 100 characters. |
| 223 | +
|
| 224 | +
|
| 225 | +#### <a name="commit-header"></a>Commit Message Header |
| 226 | +
|
| 227 | +``` |
| 228 | +<type>(<scope>): <short summary> |
| 229 | + │ │ │ |
| 230 | + │ │ └─⫸ Summary in present tense. Not capitalized. No period at the end. |
| 231 | + │ │ |
| 232 | + │ └─⫸ Commit Scope: animations|bazel|benchpress|common|compiler|compiler-cli|core| |
| 233 | + │ elements|forms|http|language-service|localize|platform-browser| |
| 234 | + │ platform-browser-dynamic|platform-server|router|service-worker| |
| 235 | + │ upgrade|zone.js|packaging|changelog|docs-infra|migrations|ngcc|ve |
| 236 | + │ |
| 237 | + └─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test |
| 238 | +``` |
| 239 | +
|
| 240 | +The `<type>` and `<summary>` fields are mandatory, the `(<scope>)` field is optional. |
| 241 | +
|
| 242 | +
|
| 243 | +##### Type |
| 244 | +
|
| 245 | +Must be one of the following: |
| 246 | +
|
| 247 | +* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) |
| 248 | +* **ci**: Changes to our CI configuration files and scripts (example scopes: Circle, BrowserStack, SauceLabs) |
| 249 | +* **docs**: Documentation only changes |
| 250 | +* **feat**: A new feature |
| 251 | +* **fix**: A bug fix |
| 252 | +* **perf**: A code change that improves performance |
| 253 | +* **refactor**: A code change that neither fixes a bug nor adds a feature |
| 254 | +* **test**: Adding missing tests or correcting existing tests |
| 255 | +
|
| 256 | +
|
| 257 | +##### Scope |
| 258 | +The scope should be the name of the npm package affected (as perceived by the person reading the changelog generated from commit messages). |
| 259 | +
|
| 260 | +The following is the list of supported scopes: |
| 261 | +
|
| 262 | +* `core` |
| 263 | +
|
| 264 | +There are currently a few exceptions to the "use package name" rule: |
| 265 | +* none/empty string: useful for `test` and `refactor` changes that are done across all packages (e.g. `test: add missing unit tests`) and for docs changes that are not related to a specific package (e.g. `docs: fix typo in tutorial`). |
| 266 | +
|
| 267 | +
|
| 268 | +##### Summary |
| 269 | +
|
| 270 | +Use the summary field to provide a succinct description of the change: |
| 271 | +
|
| 272 | +* use the imperative, present tense: "change" not "changed" nor "changes" |
| 273 | +* don't capitalize the first letter |
| 274 | +* no dot (.) at the end |
| 275 | + |
| 276 | + |
| 277 | +#### <a name="commit-body"></a>Commit Message Body |
| 278 | + |
| 279 | +Just as in the summary, use the imperative, present tense: "fix" not "fixed" nor "fixes". |
| 280 | + |
| 281 | +Explain the motivation for the change in the commit message body. This commit message should explain _why_ you are making the change. |
| 282 | +You can include a comparison of the previous behavior with the new behavior in order to illustrate the impact of the change. |
| 283 | + |
| 284 | + |
| 285 | +#### <a name="commit-footer"></a>Commit Message Footer |
| 286 | + |
| 287 | +The footer can contain information about breaking changes and is also the place to reference GitHub issues, Jira tickets, and other PRs that this commit closes or is related to. |
| 288 | + |
| 289 | +``` |
| 290 | +BREAKING CHANGE: <breaking change summary> |
| 291 | +<BLANK LINE> |
| 292 | +<breaking change description + migration instructions> |
| 293 | +<BLANK LINE> |
| 294 | +<BLANK LINE> |
| 295 | +Fixes #<issue number> |
| 296 | +``` |
| 297 | + |
| 298 | +Breaking Change section should start with the phrase "BREAKING CHANGE: " followed by a summary of the breaking change, a blank line, and a detailed description of the breaking change that also includes migration instructions. |
| 299 | + |
| 300 | + |
| 301 | +### Revert commits |
| 302 | + |
| 303 | +If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. |
| 304 | + |
| 305 | +The content of the commit message body should contain: |
| 306 | + |
| 307 | +- information about the SHA of the commit being reverted in the following format: `This reverts commit <SHA>`, |
| 308 | +- a clear description of the reason for reverting the commit message. |
| 309 | + |
| 310 | +[coc]: CODE_OF_CONDUCT.md |
| 311 | +[github]: https://github.com/osfans/trime |
| 312 | +[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit# |
0 commit comments