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