Browse code

Add some details to cherry picking for newcomers

jayunit100 authored on 2016/10/27 01:33:21
Showing 1 changed files
... ...
@@ -210,7 +210,10 @@ specifying `--ginkgo.focus` and a regex filter:
210 210
 
211 211
 Extended tests should be Go tests in the `test/extended` directory that use the Ginkgo library. They
212 212
 must be able to be run remotely, and cannot depend on any local interaction with the filesystem or
213
-Docker. More information about running extended tests can be found in [test/extended/README](https://github.com/openshift/origin/blob/master/test/extended/README.md).
213
+Docker.
214
+
215
+More information about running extended tests can be found in
216
+[test/extended/README](https://github.com/openshift/origin/blob/master/test/extended/README.md).
214 217
 
215 218
 
216 219
 ## Installing Godep
... ...
@@ -224,10 +227,64 @@ OpenShift is checked into this repository.  To install `godep` locally run:
224 224
 
225 225
 If you are not updating packages you should not need godep installed.
226 226
 
227
-## Cherry-picking an upstream commit into Origin
227
+## Cherry-picking an upstream commit into Origin: Why, how, and when.
228
+
229
+Origin carries patches inside of vendor/ on top of each rebase.  Thus, origin carries upstream patches in two ways.
230
+
231
+1. *periodic rebases* against a Kubernetes commit.
232
+Eventually, any code you have in upstream kubernetes will land in Openshift via this mechanism.
233
+
234
+2. Cherry-picked patches for important *bug fixes*.  We really try to limit feature back-porting entirely.
235
+
236
+### Manually
237
+
238
+You can manually try to cherry pick a commit (by using git apply). This can easily be done in a couple of steps.
239
+
240
+- wget the patch, i.e. `wget -O /tmp/mypatch https://github.com/kubernetes/kubernetes/pull/34624.patch`
241
+- PATCH=/tmp/mypatch git apply --directory vendor/k8s.io/kubernetes $PATCH
242
+
243
+If this fails, then it's possible you may need to pick multiple commits.
244
+
245
+### For Openshift newcomers: Pick my kubernetes fix into Openshift vs. wait for the next rebase?
246
+
247
+Assuming you read the bullets above... If your patch is really far behind, for example, if there have been 5 commits
248
+modifying the directory you care about, cherry picking will be increasingly difficult and you should consider waiting
249
+for the next rebase, which will likely include the commit you care about, or at least decrease the amount of cherry picks
250
+you need to do to merge.
251
+
252
+To really know the answer, you need to know *how many commits behind you are in a particular directory*, often.
253
+
254
+To do this, just use git log, like so (using pkg/scheduler/ as an example).
255
+
256
+```
257
+MYDIR=pkg/scheduler/algorithm git log --oneline -- vendor/k8s.io/kubernetes/${MYDIR} | grep UPSTREAM | cut -d' ' -f 4-10 | head -1
258
+```
259
+
260
+The commit message printed above will tell you:
261
+- what the LAST commit in Kubernetes was (which effected "/pkg/scheduler/algorithm")
262
+- directory, which will give you an intuition about how "hot" the code you are cherry picking is.
263
+If it has changed a lot, recently, then
264
+that means you probably will want to wait for a rebase to land.
265
+
266
+### Using hack/cherry-pick
267
+
268
+For convenience, you can use `hack/cherry-pick.sh` to generate patches for Origin from upstream commits.
269
+
270
+The purpose of this command is to allow you to pull individual commits from a local kubernetes repository
271
+into origin's vendored kuberenetes in a fully automated manner.
272
+
273
+To use this command, be sure to setup remote Pull Request branches in the kubernetes repository you are using
274
+(i.e. like https://gist.github.com/piscisaureus/3342247).  Specifically, you will be doing this, to the git config
275
+you probably already have for kubernetes:
276
+
277
+```
278
+[remote "origin"]
279
+        url = https://github.com/kubernetes/kubernetes
280
+        fetch = +refs/heads/*:refs/remotes/origin/*
281
+	### Add this line
282
+        fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
283
+```
228 284
 
229
-You can use `hack/cherry-pick.sh` to generate patches for Origin from upstream commits. To use
230
-this command, be sure to setup remote branches like https://gist.github.com/piscisaureus/3342247
231 285
 so that `git show origin/pr/<number>` displays information about your branch after a `git fetch`.
232 286
 You must also have the Kubernetes repository checked out in your GOPATH (visible as `../../../k8s.io/kubernetes`),
233 287
 with openshift/kubernetes as a remote and fetched: