Skip to content

Commit b96d32e

Browse files
committedJun 2, 2021
Fetch pull request branch for backporting rebases
1 parent e387d1f commit b96d32e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎src/backport.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const backportOnce = async ({
6666
owner,
6767
repo,
6868
title,
69+
pullRequestNumber
6970
}: {
7071
base: string;
7172
body: string;
@@ -77,12 +78,14 @@ const backportOnce = async ({
7778
owner: string;
7879
repo: string;
7980
title: string;
81+
pullRequestNumber: number;
8082
}) => {
8183
const git = async (...args: string[]) => {
8284
await exec("git", args, { cwd: repo });
8385
};
8486

8587
let backportError = null;
88+
await git("fetch", "origin", `pull/${pullRequestNumber}/head`);
8689
await git("switch", base);
8790
await git("switch", "--create", head);
8891

@@ -111,7 +114,7 @@ const backportOnce = async ({
111114

112115
await git("push", "--set-upstream", "origin", head);
113116
const {
114-
data: { number: pullRequestNumber },
117+
data: { number: backportPullRequestNumber },
115118
} = await github.pulls.create({
116119
base,
117120
body,
@@ -122,7 +125,7 @@ const backportOnce = async ({
122125
});
123126
if (labelsToAdd.length > 0) {
124127
await github.issues.addLabels({
125-
issue_number: pullRequestNumber,
128+
issue_number: backportPullRequestNumber,
126129
labels: labelsToAdd,
127130
owner,
128131
repo,
@@ -269,6 +272,7 @@ const backport = async ({
269272
owner,
270273
repo,
271274
title,
275+
pullRequestNumber
272276
});
273277
} catch (error: unknown) {
274278
if (!(error instanceof Error)) {

0 commit comments

Comments
 (0)
Please sign in to comment.