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

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
When submitting a pull request (PR), please use the following guidelines:

- 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.
- If you are introducing a new feature you may want to first submit your idea
  of feedback in the [mailing list](mailto:druid-development@googlegroups.com).
- Bugfixes should include a unit-test or integration test reproducing the issue.
- Non-trivial features should include unit-test covering the new functionality.
- Make sure your code respects existing formatting conventions. We don't have a
  formal style guide yet, but use your own judgement. If you are using
  IntelliJ, you can use import our code style settings jar
  [intellij_formatting.jar](https://github.com/druid-io/druid/raw/master/intellij_formatting.jar).
- Keep formatting changes in separate commits to make code reviews easier and
  distinguish them from actual code changes.

X
Xavier Léauté 已提交
20 21 22 23
## GitHub Workflow

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

24 25 26
  https://github.com/druid-io/druid/fork

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

28 29 30
  ```sh
  git clone git@github.com:<username>/druid.git
  ```
X
Xavier Léauté 已提交
31

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

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

36 37 38
  ```
  git remote add upstream https://github.com/druid-io/druid.git
  ```
X
Xavier Léauté 已提交
39

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

42 43 44
  ```
  git fetch upstream
  ```
X
Xavier Léauté 已提交
45

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

48 49 50
  ```
  git checkout -b feature-xxx remotes/upstream/master
  ```
X
Xavier Léauté 已提交
51

52
1. Work in your feature branch
X
Xavier Léauté 已提交
53

54 55 56
  ```
  git commit -a
  ```
X
Xavier Léauté 已提交
57

58
1. Periodically rebase your changes
X
Xavier Léauté 已提交
59

60 61 62
  ```
  git pull --rebase
  ```
X
Xavier Léauté 已提交
63

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

66 67 68
  ```
  git rebase -i upstream/master
  ```
X
Xavier Léauté 已提交
69

70 71 72
  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é 已提交
73

74
1. Submit a pull-request
X
Xavier Léauté 已提交
75

76 77 78
  ```
  git push origin feature-xxx
  ```
X
Xavier Léauté 已提交
79

80
  Go to your Druid fork main page
X
Xavier Léauté 已提交
81

82
  https://github.com/<username>/druid
X
Xavier Léauté 已提交
83

84 85 86 87
  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é 已提交
88

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

92
1. Addressing code review comments
X
Xavier Léauté 已提交
93

94 95
  Repeat steps 4. through 6. to address any code review comments and
  rebase your changes if necessary.
X
Xavier Léauté 已提交
96

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

99 100 101
  ```
  git push origin [--force] feature-xxx
  ```
X
Xavier Léauté 已提交
102

103 104
  `--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é 已提交
105

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

108 109 110
  ```
  git push origin --force feature-xxx
  ```
X
Xavier Léauté 已提交
111 112 113 114 115 116 117 118


# FAQ

### Help! I merged changes from upstream and cannot figure out how to resolve conflits when rebasing!

Never fear, if you occasionally merged upgstream/master, here is another way to squash your changes into a single commit

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

121 122 123
  ```
  git branch -m feature-xxx-unclean
  ```
X
Xavier Léauté 已提交
124

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

127 128 129
  ```
  git checkout -b feature-xxx upstream/master
  ```
X
Xavier Léauté 已提交
130

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

133 134 135 136
  ```
  git merge --squash feature-xxx-unclean
  git commit
  ```
X
Xavier Léauté 已提交
137

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

140 141 142
  ```
  git push origin [--force] feature-xxx:feature-xxx
  ```