Skip to content

Commit

Permalink
improve backport experience
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellzc committed Sep 8, 2023
1 parent d616a57 commit f1884e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
26 changes: 18 additions & 8 deletions src/backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const getFailedBackportCommentBody = ({
}) => {
const worktreePath = `.worktrees/backport-${base}`;
return [
`The backport to \`${base}\` failed:`,
`The backport to \`${base}\` failed at ${runUrl}:`,
"```",
errorMessage,
"```",
Expand All @@ -191,10 +191,22 @@ const getFailedBackportCommentBody = ({
"# Delete the working tree",
`git worktree remove ${worktreePath}`,
"```",
`Then, create a pull request where the \`base\` branch is \`${base}\` and the \`compare\`/\`head\` branch is \`${head}\`.`,
`See ${runUrl} for more information.`,
"Make sure to tag `@sourcegraph/release-guild` in the pull request description.",
"Once the backport pull request is created, kindly remove the `release-blocker` from this pull request."
"If you encouter conflict, first resolve the conflict and stage all files, then run the commands below:",
"```bash",
"git cherry-pick --continue",
"# Push it to GitHub",
`git push --set-upstream origin ${head}`,
"# Go back to the original working tree",
"cd ../..",
"# Delete the working tree",
`git worktree remove ${worktreePath}`,
"```",
"",
"- [ ] Follow above instructions to backport the commit.",
`- [ ] Create a pull request where the \`base\` branch is \`${base}\` and the \`compare\`/\`head\` branch is \`${head}\`., [click here to create the pull request](https://github.com/sourcegraph/sourcegraph/compare/${base}...${head}?expand=1).`,
"- [ ] Make sure to tag `@sourcegraph/release-guild` in the pull request description.",
"- [ ] Once the backport pull request is created, kindly remove the `release-blocker` from this pull request.",
"",
].join("\n");
};

Expand All @@ -205,7 +217,6 @@ const backport = async ({
labelRegExp,
payload,
runId,
runNumber,
serverUrl,
token,
}: {
Expand Down Expand Up @@ -233,7 +244,6 @@ const backport = async ({
labelRegExp: RegExp;
payload: PullRequestClosedEvent | PullRequestLabeledEvent;
runId: number;
runNumber: number;
serverUrl: string;
token: string;
}): Promise<{ [base: string]: number }> => {
Expand Down Expand Up @@ -303,7 +313,7 @@ const backport = async ({

const title = getTitle({ base, number, title: originalTitle });
const merged_by = originalMergedBy?.login ?? "";
const runUrl = `${serverUrl}/${owner}/${repo}/actions/runs/${runId}/jobs/${runNumber}`;
const runUrl = `${serverUrl}/${owner}/${repo}/actions/runs/${runId}`;
// PRs are handled sequentially to avoid breaking GitHub's log grouping feature.
// eslint-disable-next-line no-await-in-loop
await group(`Backporting to ${base} on ${head}.`, async () => {
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const run = async () => {

const payload = context.payload as PullRequestEvent;
const runId = context.runId;
const runNumber = context.runNumber;
const serverUrl = context.serverUrl;

if (payload.action !== "closed" && payload.action !== "labeled") {
Expand All @@ -40,7 +39,6 @@ const run = async () => {
labelRegExp,
payload,
runId,
runNumber,
serverUrl,
token,
});
Expand Down

0 comments on commit f1884e8

Please sign in to comment.