diff --git a/src/lib/github/v3/createStatusComment.ts b/src/lib/github/v3/createStatusComment.ts index 6ced470b..10dad8d7 100644 --- a/src/lib/github/v3/createStatusComment.ts +++ b/src/lib/github/v3/createStatusComment.ts @@ -73,6 +73,7 @@ export function getCommentBody({ repoOwner, autoMerge, isRepoPrivate, + noUnmergedBackportsHelp, publishStatusCommentOnAbort, publishStatusCommentOnFailure, publishStatusCommentOnSuccess, @@ -171,7 +172,7 @@ ${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`; return [ '❌', result.targetBranch, - unmergedBackportsSection + unmergedBackportsSection && !noUnmergedBackportsHelp ? `**${backportFailedLabel}**${unmergedBackportsSection}` : backportFailedLabel, ]; diff --git a/src/options/ConfigOptions.ts b/src/options/ConfigOptions.ts index b591c29e..1271cb58 100644 --- a/src/options/ConfigOptions.ts +++ b/src/options/ConfigOptions.ts @@ -31,6 +31,8 @@ type Options = Partial<{ cherrypickRef: boolean; commitConflicts: boolean; commitPaths: string[]; + copySourcePRLabels: boolean; + copySourcePRReviewers: boolean; details: boolean; dir: string; draft: boolean; @@ -67,10 +69,9 @@ type Options = Partial<{ sha: string | string[]; signoff: boolean; skipRemoteConfig: boolean; + noUnmergedBackportsHelp: boolean; sourceBranch: string; sourcePRLabels: string[]; - copySourcePRLabels: boolean; - copySourcePRReviewers: boolean; targetBranchChoices: TargetBranchChoiceOrString[]; targetBranches: string[]; targetPRLabels: string[]; diff --git a/src/options/cliArgs.ts b/src/options/cliArgs.ts index c4ccf722..1ce27098 100644 --- a/src/options/cliArgs.ts +++ b/src/options/cliArgs.ts @@ -366,6 +366,11 @@ export function getOptionsFromCliArgs(processArgs: readonly string[]) { type: 'string', }) + .option('noUnmergedBackportsHelp', { + description: 'Do not list the unmerged backports in PR comment', + type: 'boolean', + }) + .option('sourceBranch', { description: `Specify a non-default branch (normally "master") to backport from`, type: 'string', diff --git a/src/options/options.test.ts b/src/options/options.test.ts index eb2c4ddd..49344d2e 100644 --- a/src/options/options.test.ts +++ b/src/options/options.test.ts @@ -227,6 +227,7 @@ describe('getOptions', () => { maxNumber: 10, multipleBranches: true, multipleCommits: false, + noUnmergedBackportsHelp: false, noVerify: true, publishStatusCommentOnAbort: false, publishStatusCommentOnFailure: false, diff --git a/src/options/options.ts b/src/options/options.ts index 443334c4..cefa5c8b 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -55,6 +55,7 @@ export const defaultConfigOptions = { reviewers: [] as Array, signoff: false, sourcePRLabels: [] as string[], + noUnmergedBackportsHelp: false, targetBranchChoices: [] as TargetBranchChoiceOrString[], targetBranches: [] as string[], targetPRLabels: [] as string[], @@ -237,11 +238,15 @@ export function getActiveOptionsFormatted(options: ValidConfigOptions) { customOptions.push(['pullNumber', `${options.pullNumber}`]); } - if (options.author && options.author !== options.authenticatedUsername) { + if (options.sha) { + customOptions.push(['sha', `${options.sha}`]); + } + + if (options.author) { customOptions.push(['author', `${options.author}`]); } - if (options.autoMerge !== defaultConfigOptions.autoMerge) { + if (options.autoMerge === true) { customOptions.push(['autoMerge', `${options.autoMerge}`]); } @@ -259,7 +264,7 @@ export function getActiveOptionsFormatted(options: ValidConfigOptions) { return ( customOptions - .map(([key, value]) => `${chalk.bold(key)}: ${value}`) - .join(' • ') + `\n` + .map(([key, value]) => `${key}: ${chalk.bold(value)}`) + .join(' 🔹 ') + `\n` ); } diff --git a/src/test/e2e/cli/date-filters.private.test.ts b/src/test/e2e/cli/date-filters.private.test.ts index 536802c8..0216afcc 100644 --- a/src/test/e2e/cli/date-filters.private.test.ts +++ b/src/test/e2e/cli/date-filters.private.test.ts @@ -18,7 +18,7 @@ describe('date filters (dateSince, dateUntil)', () => { ); expect(output).toMatchInlineSnapshot(` -"repo: backport-org/backport-e2e • sourceBranch: master • since: 2020-08-15T10:00:00.000Z • until: 2020-08-15T10:30:00.000Z +"repo: backport-org/backport-e2e 🔹 sourceBranch: master 🔹 author: sorenlouv 🔹 since: 2020-08-15T10:00:00.000Z 🔹 until: 2020-08-15T10:30:00.000Z ? Select commit (Use arrow keys) ❯ 1. Bump to 8.0.0 @@ -42,7 +42,7 @@ describe('date filters (dateSince, dateUntil)', () => { }); expect(outputWithoutPrFilter).toMatchInlineSnapshot(` -"repo: elastic/kibana • sourceBranch: main • autoMerge: true • since: 2023-09-01T00:00:00.000Z • until: 2023-10-01T00:00:00.000Z +"repo: elastic/kibana 🔹 sourceBranch: main 🔹 author: sorenlouv 🔹 autoMerge: true 🔹 since: 2023-09-01T00:00:00.000Z 🔹 until: 2023-10-01T00:00:00.000Z ? Select commit (Use arrow keys) ❯ 1. [APM] Add support for versioned APIs in diagnostics tool (#167050) @@ -58,7 +58,7 @@ describe('date filters (dateSince, dateUntil)', () => { ); expect(outputWithPrFilter).toMatchInlineSnapshot(` -"repo: elastic/kibana • sourceBranch: main • autoMerge: true • since: 2023-09-01T00:00:00.000Z • until: 2023-10-01T00:00:00.000Z +"repo: elastic/kibana 🔹 sourceBranch: main 🔹 author: sorenlouv 🔹 autoMerge: true 🔹 since: 2023-09-01T00:00:00.000Z 🔹 until: 2023-10-01T00:00:00.000Z ? Select commit (Use arrow keys) ❯ 1. [APM] Paginate big traces (#165584) 8.10" diff --git a/src/test/e2e/cli/different-merge-strategies.private.test.ts b/src/test/e2e/cli/different-merge-strategies.private.test.ts index 0b0d7202..4d091e88 100644 --- a/src/test/e2e/cli/different-merge-strategies.private.test.ts +++ b/src/test/e2e/cli/different-merge-strategies.private.test.ts @@ -21,7 +21,7 @@ describe('different-merge-strategies', () => { ); expect(output).toMatchInlineSnapshot(` -"repo: backport-org/different-merge-strategies • sourceBranch: main • maxNumber: 20 +"repo: backport-org/different-merge-strategies 🔹 sourceBranch: main 🔹 author: sorenlouv 🔹 maxNumber: 20 ? Select commit (Use arrow keys) ❯ 1. Downsides with "Rebase and merge" @@ -71,7 +71,7 @@ describe('different-merge-strategies', () => { it('runs to completion without errors', () => { expect(output).toMatchInlineSnapshot(` "- Initializing... -repo: backport-org/different-merge-strategies • sourceBranch: main • pullNumber: 9 +repo: backport-org/different-merge-strategies 🔹 sourceBranch: main 🔹 pullNumber: 9 🔹 author: sorenlouv ? Select pull request Merge pull request #9 from backport-org/many-merge-commits ✔ 100% Cloning repository from github.com (one-time operation) @@ -191,7 +191,7 @@ View pull request: this-is-a-dry-run" it('has the right output', async () => { expect(output).toMatchInlineSnapshot(` "- Initializing... -repo: backport-org/different-merge-strategies • sourceBranch: main • pullNumber: 9 +repo: backport-org/different-merge-strategies 🔹 sourceBranch: main 🔹 pullNumber: 9 🔹 author: sorenlouv ? Select pull request Merge pull request #9 from backport-org/many-merge-commits ✔ 100% Cloning repository from github.com (one-time operation) diff --git a/src/test/e2e/cli/entrypoint.cli.private.test.ts b/src/test/e2e/cli/entrypoint.cli.private.test.ts index 3a5febe1..e4efada2 100644 --- a/src/test/e2e/cli/entrypoint.cli.private.test.ts +++ b/src/test/e2e/cli/entrypoint.cli.private.test.ts @@ -111,6 +111,8 @@ Options: authenticated user [string] --repo, --upstream Repo owner and name [string] --sha, --commit Commit sha to backport [string] + --noUnmergedBackportsHelp Do not list the unmerged backports in PR + comment [boolean] --sourceBranch Specify a non-default branch (normally "master") to backport from [string] --sourcePRLabel, --sourcePrLabel Add labels to the source (original) PR [array] @@ -150,7 +152,7 @@ Or contact me directly: " ); expect(output).toMatchInlineSnapshot(` -"repo: backport-org/backport-e2e • sourceBranch: master +"repo: backport-org/backport-e2e 🔹 sourceBranch: master 🔹 author: sorenlouv ? Select commit (Use arrow keys) ❯ 1. Add sheep emoji (#9) 7.8 @@ -179,7 +181,7 @@ Or contact me directly: " ); expect(output).toMatchInlineSnapshot(` -"repo: backport-org/backport-e2e • sourceBranch: master • maxNumber: 6 +"repo: backport-org/backport-e2e 🔹 sourceBranch: master 🔹 author: sorenlouv 🔹 maxNumber: 6 ? Select commit (Use arrow keys) ❯ 1. Add sheep emoji (#9) 7.8 @@ -205,7 +207,7 @@ Or contact me directly: " ); expect(output).toMatchInlineSnapshot(` -"repo: backport-org/backport-e2e • sourceBranch: 7.x • maxNumber: 6 +"repo: backport-org/backport-e2e 🔹 sourceBranch: 7.x 🔹 author: sorenlouv 🔹 maxNumber: 6 ? Select commit (Use arrow keys) ❯ 1. Add 🍏 emoji (#5) (#6) diff --git a/src/test/e2e/cli/error-handling-interactive-mode.private.test.ts b/src/test/e2e/cli/error-handling-interactive-mode.private.test.ts index 0cb631aa..fe0df3e0 100644 --- a/src/test/e2e/cli/error-handling-interactive-mode.private.test.ts +++ b/src/test/e2e/cli/error-handling-interactive-mode.private.test.ts @@ -90,7 +90,7 @@ describe('interactive error handling', () => { stringAfter: '', }), ).toMatchInlineSnapshot(` -"repo: backport-org/repo-with-conflicts • sourceBranch: main • pullNumber: 12 +"repo: backport-org/repo-with-conflicts 🔹 sourceBranch: main 🔹 pullNumber: 12 🔹 author: sorenlouv Backporting to 7.x: diff --git a/src/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.ts b/src/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.ts index 94c867c8..4e0b5de6 100644 --- a/src/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.ts +++ b/src/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.ts @@ -49,7 +49,7 @@ describe('gracefully handle corrupted repo', () => { // second run: backport should re-create remotes and branches correctly expect(output).toMatchInlineSnapshot(` "- Initializing... -repo: backport-org/integration-test • sourceBranch: master +repo: backport-org/integration-test 🔹 sourceBranch: master 🔹 sha: 16cfd987b82f49a79ebc663506f5d215b7a81c5c 🔹 author: sorenlouv ? Select commit Bump to 8.0.0 diff --git a/src/test/e2e/cli/repo-with-backportrc-removed.private.test.ts b/src/test/e2e/cli/repo-with-backportrc-removed.private.test.ts index 24cd240f..e1803b42 100644 --- a/src/test/e2e/cli/repo-with-backportrc-removed.private.test.ts +++ b/src/test/e2e/cli/repo-with-backportrc-removed.private.test.ts @@ -14,7 +14,7 @@ describe('repo-with-backportrc-removed (missing .backportrc.json config file)', ); expect(output).toMatchInlineSnapshot(` -"repo: backport-org/repo-with-backportrc-removed • sourceBranch: main +"repo: backport-org/repo-with-backportrc-removed 🔹 sourceBranch: main 🔹 author: sorenlouv ? Select commit (Use arrow keys) ❯ 1. Rename README.me to README.md diff --git a/src/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.ts b/src/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.ts index 038d7f07..f237b2db 100644 --- a/src/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.ts +++ b/src/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.ts @@ -69,7 +69,7 @@ describe('backport-org/repo-with-changing-branchLabelMapping', () => { ); expect(output).toMatchInlineSnapshot(` -"repo: backport-org/repo-with-changing-branchLabelMapping • sourceBranch: main • pullNumber: 6 +"repo: backport-org/repo-with-changing-branchLabelMapping 🔹 sourceBranch: main 🔹 pullNumber: 6 🔹 author: sorenlouv ? Select branch (Press to select, to toggle all, to invert selection, and to proceed) diff --git a/src/test/e2e/cli/test-that-repo-can-be-cloned.private.test.ts b/src/test/e2e/cli/test-that-repo-can-be-cloned.private.test.ts index 9e6607a0..d78d9fe5 100644 --- a/src/test/e2e/cli/test-that-repo-can-be-cloned.private.test.ts +++ b/src/test/e2e/cli/test-that-repo-can-be-cloned.private.test.ts @@ -34,7 +34,7 @@ describe('test-that-repo-can-be-cloned', () => { expect(output).toContain('Cloning repository from github.com'); expect(output).toMatchInlineSnapshot(` "- Initializing... -repo: backport-org/test-that-repo-can-be-cloned • sourceBranch: main • pullNumber: 1 +repo: backport-org/test-that-repo-can-be-cloned 🔹 sourceBranch: main 🔹 pullNumber: 1 🔹 author: sorenlouv ? Select pull request Beginning of a beautiful repo (#1) ✔ 100% Cloning repository from github.com (one-time operation) @@ -56,7 +56,7 @@ View pull request: this-is-a-dry-run" expect(output).not.toContain('Cloning repository from github.com'); expect(output).toMatchInlineSnapshot(` "- Initializing... -repo: backport-org/test-that-repo-can-be-cloned • sourceBranch: main • pullNumber: 1 +repo: backport-org/test-that-repo-can-be-cloned 🔹 sourceBranch: main 🔹 pullNumber: 1 🔹 author: sorenlouv ? Select pull request Beginning of a beautiful repo (#1)