|
| 1 | +# Contributing to API Platform |
| 2 | + |
| 3 | +First of all, thank you for contributing, you're awesome! |
| 4 | + |
| 5 | +To have your code integrated in the API Platform project, there is some rules to follow, but don't panic, it's easy! |
| 6 | + |
| 7 | +## Reporting bugs |
| 8 | + |
| 9 | +If you happen to find a bug, we kindly request you to report it. However, before submitting it, please: |
| 10 | + |
| 11 | + * Check the [project documentation available online](https://api-platform.com/docs/) |
| 12 | + |
| 13 | +Then, if it appears that it's a real bug, you may report it using Github by following these 3 points: |
| 14 | + |
| 15 | + * Check if the bug is not already reported! |
| 16 | + * A clear title to resume the issue |
| 17 | + * A description of the workflow needed to reproduce the bug, |
| 18 | + |
| 19 | +> _NOTE:_ Don’t hesitate giving as much information as you can |
| 20 | +
|
| 21 | +## Pull requests |
| 22 | + |
| 23 | +### Writing a Pull Request |
| 24 | + |
| 25 | +First of all, you must decide on what branch your changes will be based. If the changes your are going to make are |
| 26 | +fully backward-compatible, you should base your changes on the latest stable branch. |
| 27 | +Otherwise, you should base your changes on the `master` branch. |
| 28 | + |
| 29 | +### Testing your changes |
| 30 | + |
| 31 | +Before sending a Pull Request, make sure the tests pass correctly: |
| 32 | + |
| 33 | +```bash |
| 34 | +yarn test |
| 35 | +``` |
| 36 | + |
| 37 | +### Matching coding standards |
| 38 | + |
| 39 | +The API Platform CRUD Generator project is inspired by the [Airbnb JavaScript style guide](https://github.com/airbnb/javascript). |
| 40 | +But don't worry, you can fix CS issues automatically using [ESLint](https://eslint.org/) tool: |
| 41 | + |
| 42 | +```bash |
| 43 | +yarn fix |
| 44 | +``` |
| 45 | + |
| 46 | +And then, add fixed file to your commit before push. |
| 47 | +Be sure to add only **your modified files**. If another files are fixed by cs tools, just revert it before commit. |
| 48 | + |
| 49 | +### Sending a Pull Request |
| 50 | + |
| 51 | +When you send a PR, just make sure that: |
| 52 | + |
| 53 | +* You add valid test cases (Behat and PHPUnit). |
| 54 | +* Tests are green. |
| 55 | +* You make a PR on the related documentation in the [api-platform/doc](https://github.com/api-platform/doc) repository. |
| 56 | +* You make the PR on the same branch you based your changes on. If you see commits |
| 57 | +that you did not make in your PR, you're doing it wrong. |
| 58 | +* Also don't forget to add a comment when you update a PR with a ping to [the maintainer](https://github.com/orgs/api-platform/people), so he/she will get a notification. |
| 59 | +* Squash your commits into one commit. (see the next chapter) |
| 60 | + |
| 61 | +All Pull Requests must include the following header: |
| 62 | + |
| 63 | +```markdown |
| 64 | +| Q | A |
| 65 | +| ------------- | --- |
| 66 | +| Bug fix? | yes/no |
| 67 | +| New feature? | yes/no |
| 68 | +| BC breaks? | no |
| 69 | +| Deprecations? | no |
| 70 | +| Tests pass? | yes |
| 71 | +| Fixed tickets | #1234, #5678 |
| 72 | +| License | MIT |
| 73 | +| Doc PR | api-platform/doc#1234 |
| 74 | +``` |
| 75 | + |
| 76 | +## Squash your commits |
| 77 | + |
| 78 | +If you have 3 commits. So start with: |
| 79 | + |
| 80 | +```bash |
| 81 | +git rebase -i HEAD~3 |
| 82 | +``` |
| 83 | + |
| 84 | +An editor will be opened with your 3 commits, all prefixed by `pick`. |
| 85 | + |
| 86 | +Replace all `pick` prefixes by `fixup` (or `f`) **except the first commit** of the list. |
| 87 | + |
| 88 | +Save and quit the editor. |
| 89 | + |
| 90 | +After that, all your commits where squashed into the first one and the commit message of the first commit. |
| 91 | + |
| 92 | +If you would like to rename your commit message type: |
| 93 | + |
| 94 | +```bash |
| 95 | +git commit --amend |
| 96 | +``` |
| 97 | + |
| 98 | +Now force push to update your PR: |
| 99 | + |
| 100 | +```bash |
| 101 | +git push --force |
| 102 | +``` |
| 103 | + |
| 104 | +# License and copyright attribution |
| 105 | + |
| 106 | +When you open a Pull Request to the API Platform project, you agree to license your code under the [MIT license](LICENSE) |
| 107 | +and to transfer the copyright on the submitted code to Kévin Dunglas. |
| 108 | + |
| 109 | +Be sure to you have the right to do that (if you are a professional, ask your company)! |
| 110 | + |
| 111 | +If you include code from another project, please mention it in the Pull Request description and credit the original author. |
0 commit comments