Debian Codegraph @

.claude/skills/creating-backports/SKILL.md

raw
1 ---
2 name: creating-backports
3 description: Create backports of a GitHub pull request that has merged into the devel branch in the upstream repository
4 user-invocable: true
5 ---
6
7 Creating Backports
8 ==================
9
10 Backport creation workflow
11 ---------------------------
12
13 ```text
14 Backporting Progress:
15 - [ ] Step 1: Verify the referenced pull request
16 - [ ] Step 2: Identify the git remote for the upstream repository
17 - [ ] Step 3: Determine the stable branches for the backport
18 - [ ] Step 4: Create the backport branches
19 - [ ] Step 5: Create pull requests
20 - [ ] Step 6: Summarize the work
21 ```
22
23 Step 1: Verify the referenced pull request
24 -------------------------------------------
25
26 Use `gh pr view <number>` to verify the PR is merged into devel and get the merge commit SHA:
27 `gh pr view <number> --json mergeCommit -q .mergeCommit.oid`
28
29 Abort if the PR is not merged or merged to wrong branch.
30
31 Step 2: Identify the git remote for the upstream repository
32 ------------------------------------------------------------
33
34 Identify the upstream remote (typically named `upstream`). If it doesn't exist, offer to create it.
35
36 Sync the local devel branch with the identified upstream remote:
37
38 - `git fetch <upstream_remote>`
39 - `git checkout devel`
40 - `git pull --rebase <upstream_remote> devel`
41
42 Step 3: Determine the stable branches for the backport
43 -------------------------------------------------------
44
45 Refer to the backport policy in `context/contributing.md`:
46
47 - Bug fixes: backported to latest stable only
48 - Critical bug fixes: backported to latest and previous stable
49 - Security issues: must be reported to [email protected] privately (not via GitHub)
50
51 Ask the user what type of fix this is and confirm the target branches before proceeding.
52
53 To identify available stable branches, run: `git ls-remote --heads <upstream_remote> 'refs/heads/stable-*'`
54
55 Step 4: Create the backport branches
56 -------------------------------------
57
58 Before creating backport branches, verify you're not on a branch you want to keep (the workflow will create and switch between multiple branches).
59
60 First, ensure stable branches are up to date:
61
62 - Run `git fetch <upstream_remote>` to get latest stable branch refs
63
64 The backport process consists of these steps:
65
66 1. Create a new branch for each stable branch: `git checkout -b backport/VERSION/PR_NUMBER <upstream_remote>/STABLE_BRANCH`
67 Example: `git checkout -b backport/2.20/1234 upstream/stable-2.20` (if upstream remote is named `upstream`)
68 2. Cherry-pick the MERGE commit from the referenced pull request into each branch using the `-x` option.
69 (The merge commit SHA was obtained in Step 1 with `gh pr view`)
70 Example: `git cherry-pick -x <merge_commit_sha>`
71 If merge conflicts are encountered:
72 - Run `git cherry-pick --abort` to abort the cherry-pick
73 - Notify the user that manual conflict resolution is required for this stable branch
74 - Explain the user can either:
75 a) Manually resolve conflicts (you can help guide them)
76 b) Skip this stable branch backport
77 - Do NOT continue with remaining branches if conflicts occur - wait for user direction
78 3. Before pushing, identify the user's fork remote:
79 - Typically named `origin`
80 - Verify with `git remote -v` that it points to the user's fork, not upstream
81 - Confirm the remote name before pushing
82 4. Push each backport branch to the user's fork remote (identified in step 3, typically `origin`):
83 `git push <fork_remote> backport/VERSION/PR_NUMBER`
84 Example: `git push origin backport/2.20/1234` (if fork remote is named `origin`)
85 Never push to the upstream remote - this would push directly to the upstream repository.
86
87 Step 5: Create pull requests
88 -----------------------------
89
90 Confirm with the user that they would like to create a pull request for each backport branch.
91
92 Use `gh pr create` for each branch:
93
94 - `--base STABLE_BRANCH_NAME` (the stable branch being backported to)
95 - `--title "[STABLE_BRANCH_NAME] ORIGINAL_PR_TITLE"`
96 - `--body "Backport of PR #XXXX\n\n(cherry picked from commit COMMIT_HASH)"`
97
98 Example: `gh pr create --base stable-2.20 --title "[stable-2.20] Fix bug in module" --body "Backport of PR #1234\n\n(cherry picked from commit abc123)"`
99
100 Step 6: Summarize the work
101 ---------------------------
102
103 Give the user a summary of the backports that were created. The summary must provide a list of the URL links to all
104 pull requests that were created.
105
106 Error Recovery
107 --------------
108
109 If errors occur during the backport process:
110
111 - **Cherry-pick conflicts**: List which branches succeeded and which failed due to conflicts
112 - **PR creation failures**: Clean up any orphaned branches that weren't converted to PRs
113 - **Partial success**: Summarize what succeeded and offer to retry failed branches individually