2015-01-28 16:05:15 -05:00
# How to Contribute
2015-02-03 13:15:20 -05:00
When submitting a pull request (PR), please use the following guidelines:
2015-11-20 00:30:28 -05:00
- Make sure your code respects existing formatting conventions. In general, follow
the same coding style as the code that you are modifying. If you are using
2016-05-18 15:42:21 -04:00
IntelliJ, you can import our code style settings xml:
2016-05-18 16:46:53 -04:00
[druid_intellij_formatting.xml ](https://github.com/druid-io/druid/raw/master/druid_intellij_formatting.xml ).
2015-11-20 00:30:28 -05:00
- Do add/update documentation appropriately for the change you are making.
- If you are introducing a new feature you may want to first submit your idea
for feedback to the [mailing list ](mailto:druid-development@googlegroups.com ).
Non-trivial features should include unit tests covering the new functionality.
- Bugfixes should include a unit test or integration test reproducing the issue.
- Do not use author tags/information in the code.
- Always include license header on each java file your create. See [this example ](https://github.com/druid-io/druid/blob/master/common/src/main/java/io/druid/metadata/PasswordProvider.java )
2015-02-03 13:15:20 -05:00
- Try to keep pull requests short and submit separate ones for unrelated
features, but feel free to combine simple bugfixes/tests into one pull request.
- Keep the number of commits small and combine commits for related changes.
Each commit should compile on its own and ideally pass tests.
- Keep formatting changes in separate commits to make code reviews easier and
distinguish them from actual code changes.
2015-01-28 16:05:15 -05:00
## GitHub Workflow
1. Fork the druid-io/druid repository into your GitHub account
2015-02-03 13:15:20 -05:00
https://github.com/druid-io/druid/fork
1. Clone your fork of the GitHub repository
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```sh
git clone git@github.com:< username > /druid.git
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
replace `<username>` with your GitHub username.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. Add a remote to keep up with upstream changes
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git remote add upstream https://github.com/druid-io/druid.git
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
If you already have a copy, fetch upstream changes
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git fetch upstream
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. Create a feature branch to work in
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git checkout -b feature-xxx remotes/upstream/master
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. Work in your feature branch
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git commit -a
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. Periodically rebase your changes
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git pull --rebase
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. When done, combine ("squash") related commits into a single one
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git rebase -i upstream/master
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
This will open your editor and allow you to re-order commits and merge them:
- Re-order the lines to change commit order (to the extent possible without creating conflicts)
- Prefix commits using `s` (squash) or `f` (fixup) to merge extraneous commits.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. Submit a pull-request
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git push origin feature-xxx
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
Go to your Druid fork main page
2015-01-28 16:05:15 -05:00
2015-03-23 17:10:29 -04:00
```
2015-02-03 13:15:20 -05:00
https://github.com/< username > /druid
2015-03-23 17:10:29 -04:00
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
If you recently pushed your changes GitHub will automatically pop up a
`Compare & pull request` button for any branches you recently pushed to. If you
click that button it will automatically offer you to submit your pull-request
to the druid-io/druid repository.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
- Give your pull-request a meaningful title.
- In the description, explain your changes and the problem they are solving.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. Addressing code review comments
2015-01-28 16:05:15 -05:00
2015-03-23 17:10:29 -04:00
Repeat steps 5. through 7. to address any code review comments and
2015-02-03 13:15:20 -05:00
rebase your changes if necessary.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
Push your updated changes to update the pull request
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git push origin [--force] feature-xxx
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
`--force` may be necessary to overwrite your existing pull request in case your
commit history was changed when performing the rebase.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
Note: Be careful when using `--force` since you may lose data if you are not careful.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git push origin --force feature-xxx
```
2015-01-28 16:05:15 -05:00
# FAQ
2015-09-29 14:22:35 -04:00
### Help! I merged changes from upstream and cannot figure out how to resolve conflicts when rebasing!
2015-01-28 16:05:15 -05:00
2015-09-29 14:22:35 -04:00
Never fear! If you occasionally merged upstream/master, here is another way to squash your changes into a single commit:
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. First, rename your existing branch to something else, e.g. `feature-xxx-unclean`
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git branch -m feature-xxx-unclean
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. Checkout a new branch with the original name `feature-xxx` from upstream. This branch will supercede our old one.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git checkout -b feature-xxx upstream/master
```
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
1. Then merge your changes in your original feature branch `feature-xxx-unclean` and create a single commit.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git merge --squash feature-xxx-unclean
git commit
```
2015-01-28 16:05:15 -05:00
2015-09-29 14:22:35 -04:00
1. You can now submit this new branch and create or replace your existing pull request.
2015-01-28 16:05:15 -05:00
2015-02-03 13:15:20 -05:00
```
git push origin [--force] feature-xxx:feature-xxx
```