e50cdcf98db5e46895400075fb350c9f11b1ad54
[platform/upstream/nodejs.git] / COLLABORATOR_GUIDE.md
1 # io.js Collaborator Guide
2
3 **Contents**
4
5 * [Issues and Pull Requests](#issues-and-pull-requests)
6 * [Accepting Modifications](#accepting-modifications)
7  - [Involving the TC](#involving-the-tc)
8 * [Landing Pull Requests](#landing-pull-requests)
9  - [Technical HOWTO](#technical-howto)
10  - [I Just Made a Mistake](#i-just-made-a-mistake)
11
12 This document contains information for Collaborators of the io.js
13 project regarding maintaining the code, documentation and issues.
14
15 Collaborators should be familiar with the guidelines for new
16 contributors in [CONTRIBUTING.md](./CONTRIBUTING.md) and also
17 understand the project governance model as outlined in
18 [GOVERNANCE.md](./GOVERNANCE.md).
19
20 ## Issues and Pull Requests
21
22 Courtesy should always be shown to individuals submitting issues and
23 pull requests to the io.js project.
24
25 Collaborators should feel free to take full responsibility for
26 managing issues and pull requests they feel qualified to handle, as
27 long as this is done while being mindful of these guidelines, the
28 opinions of other Collaborators and guidance of the TC.
29
30 Collaborators may **close** any issue or pull request they believe is
31 not relevant for the future of the io.js project. Where this is
32 unclear, the issue should be left open for several days to allow for
33 additional discussion. Where this does not yield input from io.js
34 Collaborators or additional evidence that the issue has relevance, the
35 issue may be closed. Remember that issues can always be re-opened if
36 necessary.
37
38 ## Accepting Modifications
39
40 All modifications to the io.js code and documentation should be
41 performed via GitHub pull requests, including modifications by
42 Collaborators and TC members.
43
44 All pull requests must be reviewed and accepted by a Collaborator with
45 sufficient expertise who is able to take full responsibility for the
46 change. In the case of pull requests proposed by an existing
47 Collaborator, an additional Collaborator is required for sign-off.
48
49 In some cases, it may be necessary to summon a qualified Collaborator
50 to a pull request for review by @-mention.
51
52 If you are unsure about the modification and are not prepared to take
53 full responsibility for the change, defer to another Collaborator.
54
55 Before landing pull requests, sufficient time should be left for input
56 from other Collaborators. Leave at least 48 hours during the week and
57 72 hours over weekends to account for international time differences
58 and work schedules. Trivial changes (e.g. those which fix minor bugs
59 or improve performance without affecting API or causing other
60 wide-reaching impact) may be landed after a shorter delay.
61
62 Where there is no disagreement amongst Collaborators, a pull request
63 may be landed given appropriate review. Where there is discussion
64 amongst Collaborators, consensus should be sought if possible. The
65 lack of consensus may indicate the need to elevate discussion to the
66 TC for resolution (see below).
67
68 All bugfixes require a test case which demonstrates the defect. The
69 test should *fail* before the change, and *pass* after the change.
70
71 ### Involving the TC
72
73 Collaborators may opt to elevate pull requests or issues to the TC for
74 discussion by assigning the ***tc-agenda*** tag. This should be done
75 where a pull request:
76
77 - has a significant impact on the codebase,
78 - is inherently controversial; or
79 - has failed to reach consensus amongst the Collaborators who are
80   actively participating in the discussion.
81
82 The TC should serve as the final arbiter where required.
83
84 ## Landing Pull Requests
85
86 Always modify the original commit message to include additional meta
87 information regarding the change process:
88
89 - A `Reviewed-By: Name <email>` line for yourself and any
90   other Collaborators who have reviewed the change.
91 - A `PR-URL:` line that references the full GitHub URL of the original
92   pull request being merged so it's easy to trace a commit back to the
93   conversation that led up to that change.
94 - A `Fixes: X` line, where _X_ is either includes the full GitHub URL
95   for an issue, and/or the hash and commit message if the commit fixes
96   a bug in a previous commit. Multiple `Fixes:` lines may be added if
97   appropriate.
98
99 See the commit log for examples such as
100 [this one](https://github.com/nodejs/io.js/commit/b636ba8186) if unsure
101 exactly how to format your commit messages.
102
103 Additionally:
104
105 - Double check PRs to make sure the person's _full name_ and email
106   address are correct before merging.
107 - Except when updating dependencies, all commits should be self
108   contained (meaning every commit should pass all tests). This makes
109   it much easier when bisecting to find a breaking change.
110
111 ### Technical HOWTO
112
113 _Optional:_ ensure that you are not in a borked `am`/`rebase` state
114
115 ```text
116 $ git am --abort
117 $ git rebase --abort
118 ```
119
120 Checkout proper target branch
121
122 ```text
123 $ git checkout master
124 ```
125
126 Update the tree
127
128 ```text
129 $ git fetch origin
130 $ git merge --ff-only origin/master
131 ```
132
133 Apply external patches
134
135 ```text
136 $ curl -L https://github.com/nodejs/io.js/pull/xxx.patch | git am --whitespace=fix
137 ```
138
139 Check and re-review the changes
140
141 ```text
142 $ git diff origin/master
143 ```
144
145 Check number of commits and commit messages
146
147 ```text
148 $ git log origin/master...master
149 ```
150
151 If there are multiple commits that relate to the same feature or
152 one with a feature and separate with a test for that feature,
153 you'll need to use `squash` or `fixup`:
154
155 ```text
156 $ git rebase -i origin/master
157 ```
158
159 This will open a screen like this (in the default shell editor):
160
161 ```text
162 pick 6928fc1 crypto: add feature A
163 pick 8120c4c add test for feature A
164 pick 51759dc feature B
165 pick 7d6f433 test for feature B
166
167 # Rebase f9456a2..7d6f433 onto f9456a2
168 #
169 # Commands:
170 #  p, pick = use commit
171 #  r, reword = use commit, but edit the commit message
172 #  e, edit = use commit, but stop for amending
173 #  s, squash = use commit, but meld into previous commit
174 #  f, fixup = like "squash", but discard this commit's log message
175 #  x, exec = run command (the rest of the line) using shell
176 #
177 # These lines can be re-ordered; they are executed from top to bottom.
178 #
179 # If you remove a line here THAT COMMIT WILL BE LOST.
180 #
181 # However, if you remove everything, the rebase will be aborted.
182 #
183 # Note that empty commits are commented out
184 ```
185
186 Replace a couple of `pick`s with `fixup` to squash them into a
187 previous commit:
188
189 ```text
190 pick 6928fc1 crypto: add feature A
191 fixup 8120c4c add test for feature A
192 pick 51759dc feature B
193 fixup 7d6f433 test for feature B
194 ```
195
196 Replace `pick` with `reword` to change the commit message:
197
198 ```text
199 reword 6928fc1 crypto: add feature A
200 fixup 8120c4c add test for feature A
201 reword 51759dc feature B
202 fixup 7d6f433 test for feature B
203 ```
204
205 Save the file and close the editor. You'll be asked to enter a new
206 commit message for that commit. This is a good moment to fix incorrect
207 commit logs, ensure that they are properly formatted, and add
208 `Reviewed-By` lines.
209
210 Time to push it:
211
212 ```text
213 $ git push origin master
214 ```
215
216 ### I Just Made a Mistake
217
218 With `git`, there's a way to override remote trees by force pushing
219 (`git push -f`). This should generally be seen as forbidden (since
220 you're rewriting history on a repository other people are working
221 against) but is allowed for simpler slip-ups such as typos in commit
222 messages. However, you are only allowed to force push to any io.js
223 branch within 10 minutes from your original push. If someone else
224 pushes to the branch or the 10 minute period passes, consider the
225 commit final.