CONTRIBUTING.md 4.4 KB
Newer Older
X
Xavier Léauté 已提交
1 2
# How to Contribute

3 4
When submitting a pull request (PR), please use the following guidelines:

H
Himanshu Gupta 已提交
5 6
- 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
7
  IntelliJ, you can import our code style settings xml:
8
  [druid_intellij_formatting.xml](https://github.com/druid-io/druid/raw/master/druid_intellij_formatting.xml).
H
Himanshu Gupta 已提交
9 10 11 12 13 14 15
- 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)
16 17 18 19 20 21 22
- 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.

X
Xavier Léauté 已提交
23 24 25 26
## GitHub Workflow

1. Fork the druid-io/druid repository into your GitHub account

27 28 29
  https://github.com/druid-io/druid/fork

1. Clone your fork of the GitHub repository
X
Xavier Léauté 已提交
30

31 32 33
  ```sh
  git clone git@github.com:<username>/druid.git
  ```
X
Xavier Léauté 已提交
34

35
  replace `<username>` with your GitHub username.
X
Xavier Léauté 已提交
36

37
1. Add a remote to keep up with upstream changes
X
Xavier Léauté 已提交
38

39 40 41
  ```
  git remote add upstream https://github.com/druid-io/druid.git
  ```
X
Xavier Léauté 已提交
42

43
  If you already have a copy, fetch upstream changes
X
Xavier Léauté 已提交
44

45 46 47
  ```
  git fetch upstream
  ```
X
Xavier Léauté 已提交
48

49
1. Create a feature branch to work in
X
Xavier Léauté 已提交
50

51 52 53
  ```
  git checkout -b feature-xxx remotes/upstream/master
  ```
X
Xavier Léauté 已提交
54

55
1. Work in your feature branch
X
Xavier Léauté 已提交
56

57 58 59
  ```
  git commit -a
  ```
X
Xavier Léauté 已提交
60

61
1. Periodically rebase your changes
X
Xavier Léauté 已提交
62

63 64 65
  ```
  git pull --rebase
  ```
X
Xavier Léauté 已提交
66

67
1. When done, combine ("squash") related commits into a single one
X
Xavier Léauté 已提交
68

69 70 71
  ```
  git rebase -i upstream/master
  ```
X
Xavier Léauté 已提交
72

73 74 75
  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.
X
Xavier Léauté 已提交
76

77
1. Submit a pull-request
X
Xavier Léauté 已提交
78

79 80 81
  ```
  git push origin feature-xxx
  ```
X
Xavier Léauté 已提交
82

83
  Go to your Druid fork main page
X
Xavier Léauté 已提交
84

C
Charles Allen 已提交
85
  ```
86
  https://github.com/<username>/druid
C
Charles Allen 已提交
87
  ```
X
Xavier Léauté 已提交
88

89 90 91 92
  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.
X
Xavier Léauté 已提交
93

94 95
  - Give your pull-request a meaningful title.
  - In the description, explain your changes and the problem they are solving.
X
Xavier Léauté 已提交
96

97
1. Addressing code review comments
X
Xavier Léauté 已提交
98

C
Charles Allen 已提交
99
  Repeat steps 5. through 7. to address any code review comments and
100
  rebase your changes if necessary.
X
Xavier Léauté 已提交
101

102
  Push your updated changes to update the pull request
X
Xavier Léauté 已提交
103

104 105 106
  ```
  git push origin [--force] feature-xxx
  ```
X
Xavier Léauté 已提交
107

108 109
  `--force` may be necessary to overwrite your existing pull request in case your
  commit history was changed when performing the rebase.
X
Xavier Léauté 已提交
110

111
  Note: Be careful when using `--force` since you may lose data if you are not careful.
X
Xavier Léauté 已提交
112

113 114 115
  ```
  git push origin --force feature-xxx
  ```
X
Xavier Léauté 已提交
116 117 118 119


# FAQ

120
### Help! I merged changes from upstream and cannot figure out how to resolve conflicts when rebasing!
X
Xavier Léauté 已提交
121

122
Never fear! If you occasionally merged upstream/master, here is another way to squash your changes into a single commit:
X
Xavier Léauté 已提交
123

124
1. First, rename your existing branch to something else, e.g. `feature-xxx-unclean`
X
Xavier Léauté 已提交
125

126 127 128
  ```
  git branch -m feature-xxx-unclean
  ```
X
Xavier Léauté 已提交
129

130
1. Checkout a new branch with the original name `feature-xxx` from upstream. This branch will supercede our old one.
X
Xavier Léauté 已提交
131

132 133 134
  ```
  git checkout -b feature-xxx upstream/master
  ```
X
Xavier Léauté 已提交
135

136
1. Then merge your changes in your original feature branch `feature-xxx-unclean` and create a single commit.
X
Xavier Léauté 已提交
137

138 139 140 141
  ```
  git merge --squash feature-xxx-unclean
  git commit
  ```
X
Xavier Léauté 已提交
142

143
1. You can now submit this new branch and create or replace your existing pull request.
X
Xavier Léauté 已提交
144

145 146 147
  ```
  git push origin [--force] feature-xxx:feature-xxx
  ```