HOWTO backport commits » History » Version 34
Nathan Cutler, 12/10/2015 09:22 AM
add whitespace tip
1 | 24 | Loïc Dachary | h3. Backport commits |
---|---|---|---|
2 | 1 | Loïc Dachary | |
3 | 18 | Loïc Dachary | * Pick one entry with the highest *Priority* field in the list of backports linked from [[HOWTO|the top level page]] (for instance "hammer backports":http://tracker.ceph.com/projects/ceph/issues?query_id=78) |
4 | 23 | Nathan Cutler | * <code>git clone</code> a fork of http://github.com/ceph/ceph |
5 | * <code>git checkout -b wip-$issue-$release origin/$release</code> to create a branch with a name that reflects the issue being fixed and the target release: this naming is convenient to select all branches containing backports for firefly or select all branches containing backports for a specific issue |
||
6 | 32 | Loïc Dachary | * <code>git cherry-pick -x</code> the commits from the pull request that was targeting <code>master</code> (not from the pull requests targeting stable branches -- with the exception of the upcoming stable branch, which can be used because all commits to the upcoming stable branch are merged into <code>master</code> on a regular basis) |
7 | 19 | Loïc Dachary | ** the original issue is linked in the *Related issues* section of the issue, as a *Copied from* link |
8 | ** the pull request or commit targeting master can be found by following the *Copied from* link and searching the original issue |
||
9 | 34 | Nathan Cutler | ** TIP: if the cherry-pick fails due to whitespace differences, use <code>-Xignore-all-space</code> |
10 | 23 | Nathan Cutler | * <code>git push origin wip-$issue-$release</code> to publish the branch on github and be able to create a pull request from it |
11 | 16 | Loïc Dachary | * generate a *$github_token* by "following the GitHub instructions":https://help.github.com/articles/creating-an-access-token-for-command-line-use/ |
12 | 14 | Loïc Dachary | * retrieve the *$redmine_key*: it is a token that will allow you to script issue updates |
13 | ** login http://tracker.ceph.com/ |
||
14 | ** visit http://tracker.ceph.com/my/account |
||
15 | ** look for *API access key* in the page (Control-f) |
||
16 | ** click on the *Show* link just under *API access key* |
||
17 | ** copy the hexadecimal number it shows |
||
18 | ** redmine_key=b586ce6a7a936e71f351c93ac0b65a588d4333 |
||
19 | 23 | Nathan Cutler | * create a pull request from the <code>wip-$issue-$release</code> branch with the same title as the issue |
20 | 7 | Loïc Dachary | <pre> |
21 | 10 | Loïc Dachary | account=myaccount |
22 | 7 | Loïc Dachary | eval title=$(curl --silent 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key | jq .issue.subject) ; echo $title |
23 | 10 | Loïc Dachary | number=$(curl --silent --data-binary '{"title":"'"$title"'","head":"'$account':wip-'$issue-$release'","base":"'$release'","body":"http://tracker.ceph.com/issues/'$issue'"}' 'https://api.github.com/repos/ceph/ceph/pulls?access_token='$github_token | jq .number) |
24 | </pre> |
||
25 | 13 | Loïc Dachary | * assigned the pull request to yourself (because it needs to got through integration tests before it can be approved by the original author), add the relevant labels (rgw, core, bug fix, feature...) and set the milestone to $release (requires write permission to the ceph repository) |
26 | 10 | Loïc Dachary | <pre> |
27 | component=core ; curl --silent --data-binary '{"milestone":"'$release_number'","assignee":"'$account'","labels":["bug fix","'$component'"]}' 'https://api.github.com/repos/ceph/ceph/issues/'$number'?access_token='$github_token |
||
28 | </pre> |
||
29 | * wait for the make check bot to run the *run-make-check.sh* script on the branch that was pushed and verify it works |
||
30 | 29 | Loïc Dachary | * Set the issue description to only contain the URL to the pull request and change the status to *In Progress* |
31 | 1 | Loïc Dachary | <pre> |
32 | 29 | Loïc Dachary | redmine_status=2 # In Progress |
33 | curl --verbose -X PUT --header 'Content-type: application/json' --data-binary '{"issue":{"description":"https://github.com/ceph/ceph/pull/'$number'","status_id":'$redmine_status'}}' 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key |
||
34 | 2 | Loïc Dachary | </pre> |
35 | * if there is a conflict explain how it was resolved in the commit message, below the Conflicts line. For instance: |
||
36 | <pre> |
||
37 | commit c60da2f3c34e7325c748d2d6e55140a0a30013fd |
||
38 | Author: Samuel Just <sjust@redhat.com> |
||
39 | Date: Thu Nov 20 15:15:08 2014 -0800 |
||
40 | 1 | Loïc Dachary | |
41 | PGLog: include rollback_info_trimmed_to in (read|write)_log |
||
42 | |||
43 | Fixes: #10157 |
||
44 | Backport: firefly, giant |
||
45 | Signed-off-by: Samuel Just <sjust@redhat.com> |
||
46 | (cherry picked from commit 1fe8b846641486cc294fe7e1d2450132c38d2dba) |
||
47 | |||
48 | Conflicts: |
||
49 | src/osd/PGLog.cc |
||
50 | in the context coll_t::META_COLL was replaced with META_COLL |
||
51 | </pre> |
||
52 | * The difference between the original commit and the one including a conflict resolution can be displayed with |
||
53 | 11 | Loïc Dachary | <pre> |
54 | commit=c7d0d51cb574594de6f09457c960347b11fc2474 ; picked_from=$(git show --no-patch --pretty=%b $commit | perl -ne 'print if(s/.*cherry picked from commit (\w+).*/$1/)') ; diff -u --ignore-matching-lines '^[^+-]' <(git show $picked_from) <(git show $commit) |
||
55 | </pre> |
||
56 | 18 | Loïc Dachary | * if the conflict is difficult to resolve, seek help from the author of the original commit (see "librbd: deadlock in image refresh":https://github.com/ceph/ceph/pull/4176 for instance) and assign the issue to her/him, or to a [[HOWTO#Leads|lead]] |
57 | 25 | Nathan Cutler | |
58 | Do not merge the pull request yet. Merging only takes place after the backports pass [[HOWTO run integration and upgrade tests|integration and upgrade tests]] and with proper approval as described in [[HOWTO merge commits from the integration branch]]. |
||
59 | 1 | Loïc Dachary | |
60 | 28 | Nathan Cutler | When the backport PR is opened, you can update the backport tracker issue: set *Status* to "In Progress" and *Target version* to the version you are working on. |
61 | |||
62 | 10 | Loïc Dachary | All commits being backported must be cherry-picked from master. There are exceptions to this rule (see https://github.com/ceph/ceph/pull/4175 for instance: it fixes a regression introduced by an incorrect resolution of a backport) but they are rare. When a backport is done to fix a bug that shows in the integration tests or upgrade tests run by cron, testing the backport in an integration branch is redundant because the existing tests will keep failing. |
63 | |||
64 | 17 | Nathan Cutler | Here are the snippets above grouped together for easier copy/paste: |
65 | 10 | Loïc Dachary | <pre> |
66 | 33 | Nathan Cutler | set -x |
67 | 10 | Loïc Dachary | redmine_key=b586c588d4333 |
68 | 30 | Loïc Dachary | redmine_user_id=789 # as found in the URL near "Logged in as " top right of each page |
69 | 10 | Loïc Dachary | github_token=bc275830c635 |
70 | 12 | Loïc Dachary | github_user=dachary |
71 | 10 | Loïc Dachary | issue=$1 |
72 | # can't seem to extract the release number with the api |
||
73 | release=giant ; release_number=2 |
||
74 | 1 | Loïc Dachary | release=firefly ; release_number=3 |
75 | release=hammer ; release_number=5 |
||
76 | release=infernalis ; release_number=7 |
||
77 | 33 | Nathan Cutler | if [ $(curl --silent http://tracker.ceph.com/issues/$issue.json | jq -r .issue.tracker.name) != "Backport" ] |
78 | then |
||
79 | echo "not a backport issue" |
||
80 | exit 1 |
||
81 | fi |
||
82 | 12 | Loïc Dachary | git checkout -f -b wip-$issue-$release ceph/$release |
83 | git cherry-pick -x ..... |
||
84 | 10 | Loïc Dachary | git push loic wip-$issue-$release ; sleep 2 # let github catch up |
85 | 1 | Loïc Dachary | title=$(curl --silent 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key | jq .issue.subject | tr -d '\\"') |
86 | 17 | Nathan Cutler | echo "Issue title: $title" |
87 | 22 | Loïc Dachary | number=$(curl --silent --data-binary '{"title":"'"$title"'","head":"'$github_user':wip-'$issue-$release'","base":"'$release'","body":"http://tracker.ceph.com/issues/'$issue'"}' 'https://api.github.com/repos/ceph/ceph/pulls?access_token='$github_token | jq .number) |
88 | 1 | Loïc Dachary | echo "Opened pull request $number" |
89 | component=core ; curl --silent --data-binary '{"milestone":"'$release_number'","assignee":"'$github_user'","labels":["bug fix","'$component'"]}' 'https://api.github.com/repos/ceph/ceph/issues/'$number'?access_token='$github_token |
||
90 | 12 | Loïc Dachary | firefox https://github.com/ceph/ceph/pull/$number |
91 | 1 | Loïc Dachary | redmine_status=2 # In Progress |
92 | 30 | Loïc Dachary | curl --verbose -X PUT --header 'Content-type: application/json' --data-binary '{"issue":{"description":"https://github.com/ceph/ceph/pull/'$number'","status_id":'$redmine_status',"assigned_to_id":'$redmine_user_id'}}' 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key |
93 | 10 | Loïc Dachary | firefox http://tracker.ceph.com/issues/$issue |
94 | </pre> |
||
95 | 26 | Nathan Cutler | |
96 | 29 | Loïc Dachary | If you would like to automate update of the tracker target version, try something like this instead of the last <code>curl</code> command: |
97 | 26 | Nathan Cutler | <pre> |
98 | curl --verbose -X PUT --header 'Content-type: application/json' --data-binary '{"issue":{"description":"https://github.com/ceph/ceph/pull/'$number'","status_id":'$redmine_status',"fixed_version_id":'$redmine_fixed_version'}}' 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key |
||
99 | </pre> |
||
100 | 27 | Nathan Cutler | The values of <code>$redmine_status</code> and <code>$redmine_fixed_version</code> can be determined by setting the desired values in an issue and then peeking at the JSON using a command like this: |
101 | <pre> |
||
102 | curl --silent 'http://tracker.ceph.com/issues/12395.json' |
||
103 | </pre> |