2016-10-06 18:07:46 -04:00
# Contributing to Angular
2015-03-10 15:41:35 -04:00
2016-10-06 18:07:46 -04:00
We would love for you to contribute to Angular and help make it even better than it is
2015-03-10 15:41:35 -04:00
today! As a contributor, here are the guidelines we would like you to follow:
- [Code of Conduct ](#coc )
- [Question or Problem? ](#question )
- [Issues and Bugs ](#issue )
- [Feature Requests ](#feature )
- [Submission Guidelines ](#submit )
- [Coding Rules ](#rules )
- [Commit Message Guidelines ](#commit )
- [Signing the CLA ](#cla )
## <a name="coc"></a> Code of Conduct
Help us keep Angular open and inclusive. Please read and follow our [Code of Conduct][coc].
## <a name="question"></a> Got a Question or Problem?
2017-07-11 15:40:30 -04:00
Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on [Stack Overflow ](https://stackoverflow.com/questions/tagged/angular ) where the questions should be tagged with tag `angular` .
2015-03-10 15:41:35 -04:00
2017-04-08 11:38:49 -04:00
Stack Overflow is a much better place to ask questions since:
2016-10-06 16:58:14 -04:00
2017-04-08 11:38:49 -04:00
- there are thousands of people willing to help on Stack Overflow
2016-10-06 16:58:14 -04:00
- questions and answers stay available for public viewing so your question / answer might help someone else
2017-04-08 11:38:49 -04:00
- Stack Overflow's voting system assures that the best answers are prominently visible.
2016-10-06 16:58:14 -04:00
2017-07-11 15:40:30 -04:00
To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow.
2016-10-06 16:58:14 -04:00
If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter].
2016-10-10 12:14:35 -04:00
## <a name="issue"></a> Found a Bug?
2016-08-26 18:35:33 -04:00
If you find a bug in the source code, you can help us by
2015-03-10 15:41:35 -04:00
[submitting an issue ](#submit-issue ) to our [GitHub Repository][github]. Even better, you can
[submit a Pull Request ](#submit-pr ) with a fix.
2016-10-06 18:06:37 -04:00
## <a name="feature"></a> Missing a Feature?
You can *request* a new feature by [submitting an issue ](#submit-issue ) to our GitHub
Repository. If you would like to *implement* a new feature, please submit an issue with
2016-09-22 13:31:56 -04:00
a proposal for your work first, to be sure that we can use it.
2015-05-29 18:32:31 -04:00
Please consider what kind of change it is:
2015-03-10 15:41:35 -04:00
* For a **Major Feature** , first open an issue and outline your proposal so that it can be
discussed. This will also allow 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.
* **Small Features** can be crafted and directly [submitted as a Pull Request ](#submit-pr ).
## <a name="submit"></a> Submission Guidelines
### <a name="submit-issue"></a> Submitting an Issue
2016-10-06 18:06:37 -04:00
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.
2018-02-18 06:10:12 -05:00
We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs, we will systematically ask you to provide a minimal reproduction scenario using http://plnkr.co. Having a live, reproducible scenario gives us a wealth of important information without going back & forth to you with additional questions like:
2016-10-06 18:06:37 -04:00
- version of Angular used
- 3rd-party libraries and their versions
- and most importantly - a use-case that fails
2016-12-05 13:25:20 -05:00
A minimal reproduce scenario using http://plnkr.co/ allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem. If plunker is not a suitable way to demonstrate the problem (for example for issues related to our npm packaging), please create a standalone git repository demonstrating the problem.
2016-10-06 18:06:37 -04:00
We will be insisting on a minimal reproduce scenario in order to save maintainers time and ultimately be able to fix more bugs. Interestingly, from our experience users often find coding problems themselves while preparing a minimal plunk. We understand that sometimes it might be hard to extract essentials bits of code from a larger code-base but we really need to isolate the problem before we can fix it.
2018-02-18 06:10:12 -05:00
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.
2016-10-06 18:06:37 -04:00
2018-12-02 09:33:08 -05:00
You can file new issues by selecting from our [new issue templates ](https://github.com/angular/angular/issues/new/choose ) and filling out the form.
2015-12-14 19:19:22 -05:00
2015-03-10 15:41:35 -04:00
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
Before you submit your Pull Request (PR) consider the following guidelines:
2017-11-15 14:29:28 -05:00
1. Search [GitHub ](https://github.com/angular/angular/pulls ) for an open or closed PR
2015-03-10 15:41:35 -04:00
that relates to your submission. You don't want to duplicate effort.
2018-08-10 18:19:33 -04:00
1. Be sure that an issue describes the problem you're fixing, or documents the design for the feature you'd like to add.
Discussing the design up front helps to ensure that we're ready to accept your work.
2017-11-15 14:29:28 -05:00
1. Please sign our [Contributor License Agreement (CLA) ](#cla ) before sending PRs.
2018-01-26 11:33:41 -05:00
We cannot accept code without this. Make sure you sign with the primary email address of the Git identity that has been granted access to the Angular repository.
2017-11-15 14:29:28 -05:00
1. Fork the angular/angular repo.
1. Make your changes in a new git branch:
2015-03-10 15:41:35 -04:00
```shell
git checkout -b my-fix-branch master
```
2017-11-15 14:29:28 -05:00
1. Create your patch, **including appropriate test cases** .
1. Follow our [Coding Rules ](#rules ).
1. Run the full Angular test suite, as described in the [developer documentation][dev-doc],
2015-03-10 15:41:35 -04:00
and ensure that all tests pass.
2017-11-15 14:29:28 -05:00
1. Commit your changes using a descriptive commit message that follows our
2015-03-10 15:41:35 -04:00
[commit message conventions ](#commit ). Adherence to these conventions
is necessary because release notes are automatically generated from these messages.
```shell
git commit -a
```
2017-11-15 14:29:28 -05:00
Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files.
2015-03-10 15:41:35 -04:00
2017-11-15 14:29:28 -05:00
1. Push your branch to GitHub:
2015-03-10 15:41:35 -04:00
```shell
git push origin my-fix-branch
```
2017-11-15 14:29:28 -05:00
1. In GitHub, send a pull request to `angular:master` .
2015-03-10 15:41:35 -04:00
* If we suggest changes then:
* Make the required updates.
2016-10-06 18:07:46 -04:00
* Re-run the Angular test suites to ensure tests are still passing.
2015-03-10 15:41:35 -04:00
* Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
```shell
git rebase master -i
git push -f
```
That's it! Thank you for your contribution!
#### After your pull request is merged
After your pull request is merged, you can safely delete your branch and pull the changes
from the main (upstream) repository:
* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
```shell
git push origin --delete my-fix-branch
```
* Check out the master branch:
```shell
git checkout master -f
```
* Delete the local branch:
```shell
git branch -D my-fix-branch
```
* Update your master with the latest upstream version:
```shell
git pull --ff upstream master
```
## <a name="rules"></a> Coding Rules
To ensure consistency throughout the source code, keep these rules in mind as you are working:
* All features or bug fixes **must be tested** by one or more specs (unit-tests).
* All public API methods **must be documented** . (Details TBC).
2015-06-22 12:45:53 -04:00
* We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at
**100 characters** . An automated formatter is available, see
2017-03-24 11:14:23 -04:00
[DEVELOPER.md ](docs/DEVELOPER.md#clang-format ).
2015-06-19 19:30:03 -04:00
2015-03-10 15:41:35 -04:00
## <a name="commit"></a> Commit Message Guidelines
We have very precise rules over how our git commit messages can be formatted. This leads to **more
readable messages** that are easy to follow when looking through the **project history** . But also,
we use the git commit messages to **generate the Angular change log** .
### Commit Message Format
Each commit message consists of a **header** , a **body** and a **footer** . The header has a special
format that includes a **type** , a **scope** and a **subject** :
```
< type > (< scope > ): < subject >
< BLANK LINE >
< body >
< BLANK LINE >
< footer >
```
2015-08-04 07:14:52 -04:00
The **header** is mandatory and the **scope** of the header is optional.
2015-03-10 15:41:35 -04:00
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier
to read on GitHub as well as in various git tools.
2018-02-18 06:10:12 -05:00
The footer should contain a [closing reference to an issue ](https://help.github.com/articles/closing-issues-via-commit-messages/ ) if any.
2016-05-19 18:19:01 -04:00
Samples: (even more [samples ](https://github.com/angular/angular/commits/master ))
```
2018-02-18 06:10:12 -05:00
docs(changelog): update changelog to beta.5
2016-05-19 18:19:01 -04:00
```
```
fix(release): need to depend on latest rxjs and zone.js
The version in our package.json gets copied to the one we publish, and users need the latest of these.
```
2015-08-04 07:14:52 -04:00
### Revert
If the commit reverts a previous commit, it should begin with `revert: ` , followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.` , where the hash is the SHA of the commit being reverted.
2015-03-10 15:41:35 -04:00
### Type
Must be one of the following:
2017-01-19 19:24:47 -05:00
* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
* **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
* **docs**: Documentation only changes
2015-03-10 15:41:35 -04:00
* **feat**: A new feature
* **fix**: A bug fix
2017-01-19 19:24:47 -05:00
* **perf**: A code change that improves performance
* **refactor**: A code change that neither fixes a bug nor adds a feature
2017-06-22 07:06:54 -04:00
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
2015-12-08 19:26:28 -05:00
* **test**: Adding missing tests or correcting existing tests
2015-03-10 15:41:35 -04:00
### Scope
2018-02-18 06:10:12 -05:00
The scope should be the name of the npm package affected (as perceived by the person reading the changelog generated from commit messages.
2017-01-19 19:24:47 -05:00
The following is the list of supported scopes:
2017-07-05 17:34:13 -04:00
* **animations**
2017-01-19 19:24:47 -05:00
* **common**
* **compiler**
* **compiler-cli**
* **core**
2018-02-28 12:45:11 -05:00
* **elements**
2017-01-19 19:24:47 -05:00
* **forms**
* **http**
* **language-service**
* **platform-browser**
* **platform-browser-dynamic**
* **platform-server**
* **platform-webworker**
* **platform-webworker-dynamic**
* **router**
2017-10-23 12:47:45 -04:00
* **service-worker**
2017-01-19 19:24:47 -05:00
* **upgrade**
2017-05-15 07:47:19 -04:00
There are currently a few exceptions to the "use package name" rule:
2017-01-19 19:24:47 -05:00
2018-06-11 05:25:08 -04:00
* **packaging**: used for changes that change the npm package layout in all of our packages, e.g.
public path changes, package.json changes done to all packages, d.ts file/format changes, changes
to bundles, etc.
2017-01-19 19:24:47 -05:00
* **changelog**: used for updating the release notes in CHANGELOG.md
2018-06-11 05:25:08 -04:00
* **docs-infra**: used for docs-app (angular.io) related changes within the /aio directory of the
repo
* none/empty string: useful for `style` , `test` and `refactor` changes that are done across all
packages (e.g. `style: add missing semicolons` ) and for docs changes that are not related to a
specific package (e.g. `docs: fix typo in tutorial` ).
2017-01-19 19:24:47 -05:00
2015-03-10 15:41:35 -04:00
### Subject
2018-02-18 06:10:12 -05:00
The subject contains a succinct description of the change:
2015-03-10 15:41:35 -04:00
* use the imperative, present tense: "change" not "changed" nor "changes"
2018-02-18 06:10:12 -05:00
* don't capitalize the first letter
2015-03-10 15:41:35 -04:00
* no dot (.) at the end
### Body
Just as in the **subject** , use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.
### Footer
The footer should contain any information about **Breaking Changes** and is also the place to
reference GitHub issues that this commit **Closes** .
2015-08-04 07:14:52 -04:00
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
2015-03-10 15:41:35 -04:00
A detailed explanation can be found in this [document][commit-message-format].
## <a name="cla"></a> Signing the CLA
Please sign our Contributor License Agreement (CLA) before sending pull requests. For any code
changes to be accepted, the CLA must be signed. It's a quick process, we promise!
* For individuals we have a [simple click-through form][individual-cla].
* For corporations we'll need you to
[print, sign and one of scan+email, fax or mail the form][corporate-cla].
2018-01-26 11:33:41 -05:00
< hr >
If you have more than one Git identity, you must make sure that you sign the CLA using the primary email address associated with the ID that has been granted access to the Angular repository. Git identities can be associated with more than one email address, and only one is primary. Here are some links to help you sort out multiple Git identities and email addresses:
* https://help.github.com/articles/setting-your-commit-email-address-in-git/
* https://stackoverflow.com/questions/37245303/what-does-usera-committed-with-userb-13-days-ago-on-github-mean
* https://help.github.com/articles/about-commit-email-addresses/
2018-02-18 06:10:12 -05:00
* https://help.github.com/articles/blocking-command-line-pushes-that-expose-your-personal-email-address/
2018-01-26 11:33:41 -05:00
2018-06-11 05:25:08 -04:00
Note that if you have more than one Git identity, it is important to verify that you are logged in with the same ID with which you signed the CLA, before you commit changes. If not, your PR will fail the CLA check.
2018-01-26 11:33:41 -05:00
< hr >
2015-03-10 15:41:35 -04:00
[angular-group]: https://groups.google.com/forum/#!forum/angular
[coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
[corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html
2017-03-24 11:14:23 -04:00
[dev-doc]: https://github.com/angular/angular/blob/master/docs/DEVELOPER.md
2015-03-10 15:41:35 -04:00
[github]: https://github.com/angular/angular
[gitter]: https://gitter.im/angular/angular
[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html
2016-12-05 13:25:20 -05:00
[js-style-guide]: https://google.github.io/styleguide/jsguide.html
2016-05-18 20:18:07 -04:00
[jsfiddle]: http://jsfiddle.net
2015-03-10 15:41:35 -04:00
[plunker]: http://plnkr.co/edit
2016-05-18 20:18:07 -04:00
[runnable]: http://runnable.com
2015-03-10 15:41:35 -04:00
[stackoverflow]: http://stackoverflow.com/questions/tagged/angular