You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .claude/commands/contribute-upstream.md
+23-11Lines changed: 23 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,9 +32,21 @@ Also read the corresponding markdown report to understand the actual diff hunks
32
32
33
33
If there are zero candidates, tell the user and stop.
34
34
35
-
## Step 3: Group into PR Proposals
35
+
## Step 3: Filter Out Existing PRs
36
36
37
-
Analyze the contributable hunks across all candidate files and group them into logical PR proposals. Guidelines:
37
+
Before proposing new PRs, check what's already open from DataDog against upstream:
38
+
39
+
```bash
40
+
gh pr list --repo async-profiler/async-profiler --author DataDog --state open --json number,title,body,files
41
+
```
42
+
43
+
For each open PR, extract the list of files it touches. Then cross-reference with the candidate files from Step 2:
44
+
45
+
- If a candidate file is already fully covered by an open PR (i.e., the PR touches that file and addresses the same type of change), **exclude it** from proposals
46
+
- If a candidate file is only partially covered (the open PR addresses some hunks but not others), keep the uncovered hunks as candidates
47
+
- When presenting proposals in Step 4, mention any skipped files and the existing PR that covers them, so the user has full visibility
48
+
49
+
Analyze the remaining contributable hunks across candidate files and group them into logical PR proposals. Guidelines:
38
50
39
51
-**Related changes go together**: e.g., a bug fix touching `stackWalker.cpp` and `vmStructs.cpp` for the same issue = one PR
40
52
-**Independent changes are separate**: unrelated fixes in different files = separate PRs
@@ -46,7 +58,7 @@ For each proposed PR, prepare:
46
58
- The list of files and hunks it covers
47
59
- A brief rationale explaining why this change benefits upstream
48
60
49
-
## Step 4: Present Proposals to User
61
+
## Step 5: Present Proposals to User
50
62
51
63
Show the user a numbered list of proposed PRs with:
52
64
- Title
@@ -58,11 +70,11 @@ Use `AskUserQuestion` with `multiSelect: true` to let the user pick which PRs to
58
70
59
71
If the user selects none, stop.
60
72
61
-
## Step 5: Create Selected PRs
73
+
## Step 6: Create Selected PRs
62
74
63
75
For each selected PR, perform the following:
64
76
65
-
### 5a. Clone the Fork (once)
77
+
### 6a. Clone the Fork (once)
66
78
67
79
Clone `git@github.com:DataDog/async-profiler.git` to a temp directory. Reuse this clone for all PRs.
68
80
@@ -78,7 +90,7 @@ git checkout -b master
78
90
git branch -D temp
79
91
```
80
92
81
-
### 5b. Create Feature Branch
93
+
### 6b. Create Feature Branch
82
94
83
95
For each PR, create a branch from upstream master:
84
96
@@ -91,7 +103,7 @@ git checkout -b "$BRANCH_NAME"
91
103
92
104
Where `<slug>` is a short kebab-case description derived from the PR title.
93
105
94
-
### 5c. Port Changes
106
+
### 6c. Port Changes
95
107
96
108
Apply only the relevant contributable hunks for this PR to the upstream files:
97
109
@@ -100,7 +112,7 @@ Apply only the relevant contributable hunks for this PR to the upstream files:
100
112
3.**Critical**: Ensure NO Datadog-specific references leak through (DD_, ddprof, Datadog, datadog, DDPROF, context.h, counters.h, tagger, QueueItem)
101
113
4. If a hunk cannot be cleanly applied because the upstream file diverged, skip it and note it for the user
102
114
103
-
### 5d. Verify Build
115
+
### 6d. Verify Build
104
116
105
117
Attempt a basic build check:
106
118
@@ -111,7 +123,7 @@ make
111
123
112
124
If the build fails, analyze the error. If it's a simple fix (e.g., missing include), fix it. If it's complex, note it for the user and proceed anyway (the PR is draft).
113
125
114
-
### 5e. Commit and Push
126
+
### 6e. Commit and Push
115
127
116
128
```bash
117
129
cd"$FORK_DIR"
@@ -120,7 +132,7 @@ git commit -m "<concise description of the change>"
120
132
git push origin "$BRANCH_NAME"
121
133
```
122
134
123
-
### 5f. Open Draft PR
135
+
### 6f. Open Draft PR
124
136
125
137
Use `gh` to create a draft PR against upstream. **Important**: Before creating the first PR, fetch the target project's PR template from the upstream repo (`gh api repos/async-profiler/async-profiler/contents/.github/PULL_REQUEST_TEMPLATE.md` and decode the base64 content). The PR body **must** follow that template exactly — use all its sections, checkboxes, and footer verbatim. Fill in each section with the relevant content for this change.
126
138
@@ -134,7 +146,7 @@ gh pr create \
134
146
--body "<body following the upstream PR template>"
135
147
```
136
148
137
-
## Step 6: Report
149
+
## Step 7: Report
138
150
139
151
After all selected PRs are created, show the user:
0 commit comments