diff --git a/__snapshots__/cli.js b/__snapshots__/cli.js index 0d225b291..483c3cd2c 100644 --- a/__snapshots__/cli.js +++ b/__snapshots__/cli.js @@ -87,6 +87,8 @@ Options: --dry-run Prepare but do not take action[boolean] [default: false] --label comma-separated list of labels to add to from release PR [default: "autorelease: pending"] + --skip-labeling skip application of labels to pull requests + [boolean] [default: false] --fork should the PR be created from a fork [boolean] [default: false] --draft-pull-request mark pull request as a draft [boolean] [default: false] @@ -199,6 +201,8 @@ Options: --label comma-separated list of labels to add to from release PR [default: "autorelease: pending"] + --skip-labeling skip application of labels to pull requests + [boolean] [default: false] --fork should the PR be created from a fork [boolean] [default: false] --draft-pull-request mark pull request as a draft diff --git a/docs/cli.md b/docs/cli.md index e2d0775e8..839b1262e 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -56,6 +56,7 @@ Extra options: | `--draft-pull-request` | `boolean` | If set, create pull requests as drafts | | `--label` | `string` | Comma-separated list of labels to apply to the release pull requests. Defaults to `autorelease: pending` | | `--release-label` | `string` | Comma-separated list of labels to apply to the pull request after the release has been tagged. Defaults to `autorelease: tagged` | +| `--skip-labeling` | `boolean` | If set, labels will not be applied to pull requests | | `--changelog-path` | `string` | Override the path to the managed CHANGELOG. Defaults to `CHANGELOG.md` | | `--changelog-type` | [`ChangelogType`](/docs/customizing.md#changelog-types) | Strategy for building the changelog contents. Defaults to `default` | | `--changelog-sections` | `string` | Comma-separated list of commit scopes to show in changelog headings | diff --git a/src/bin/release-please.ts b/src/bin/release-please.ts index 99367db8b..47684cfd3 100644 --- a/src/bin/release-please.ts +++ b/src/bin/release-please.ts @@ -92,6 +92,7 @@ interface ReleaseArgs { interface PullRequestArgs { draftPullRequest?: boolean; label?: string; + skipLabeling?: boolean; signoff?: string; } @@ -230,6 +231,11 @@ function pullRequestOptions(yargs: yargs.Argv): yargs.Argv { default: 'autorelease: pending', describe: 'comma-separated list of labels to add to from release PR', }) + .option('skip-labeling', { + describe: 'skip application of labels to pull requests', + type: 'boolean', + default: false, + }) .option('fork', { describe: 'should the PR be created from a fork', type: 'boolean', @@ -757,6 +763,9 @@ function extractManifestOptions( if (labels.length === 1 && labels[0] === '') labels = []; manifestOptions.labels = labels; } + if ('skipLabeling' in argv && argv.skipLabeling !== undefined) { + manifestOptions.skipLabeling = argv.skipLabeling; + } if ('releaseLabel' in argv && argv.releaseLabel) { manifestOptions.releaseLabels = argv.releaseLabel.split(','); } diff --git a/src/github.ts b/src/github.ts index 00e25b9f7..fd83e4c01 100644 --- a/src/github.ts +++ b/src/github.ts @@ -891,12 +891,16 @@ export class GitHub { options?: { signoffUser?: string; fork?: boolean; + skipLabeling?: boolean; } ): Promise { let message = releasePullRequest.title.toString(); if (options?.signoffUser) { message = signoffCommitMessage(message, options.signoffUser); } + const pullRequestLabels: string[] = options?.skipLabeling + ? [] + : releasePullRequest.labels; return await this.createPullRequest( { headBranchName: releasePullRequest.headRefName, @@ -904,7 +908,7 @@ export class GitHub { number: -1, title: releasePullRequest.title.toString(), body: releasePullRequest.body.toString().slice(0, MAX_ISSUE_BODY_SIZE), - labels: releasePullRequest.labels, + labels: pullRequestLabels, files: [], }, targetBranch, diff --git a/src/manifest.ts b/src/manifest.ts index 4863c095f..448c521cb 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -134,6 +134,7 @@ export interface ManifestOptions { signoff?: string; manifestPath?: string; labels?: string[]; + skipLabeling?: boolean; releaseLabels?: string[]; snapshotLabels?: string[]; draft?: boolean; @@ -214,6 +215,7 @@ export class Manifest { readonly fork: boolean; private signoffUser?: string; private labels: string[]; + private skipLabeling?: boolean; private releaseLabels: string[]; private snapshotLabels: string[]; private plugins: PluginType[]; @@ -277,6 +279,7 @@ export class Manifest { this.releaseLabels = manifestOptions?.releaseLabels || DEFAULT_RELEASE_LABELS; this.labels = manifestOptions?.labels || DEFAULT_LABELS; + this.skipLabeling = manifestOptions?.skipLabeling || false; this.snapshotLabels = manifestOptions?.snapshotLabels || DEFAULT_SNAPSHOT_LABELS; this.bootstrapSha = manifestOptions?.bootstrapSha; @@ -826,6 +829,7 @@ export class Manifest { { fork: this.fork, signoffUser: this.signoffUser, + skipLabeling: this.skipLabeling, } ); return newPullRequest; diff --git a/test/cli.ts b/test/cli.ts index 0f7d15882..ffe8df873 100644 --- a/test/cli.ts +++ b/test/cli.ts @@ -264,6 +264,27 @@ describe('CLI', () => { sinon.assert.calledOnce(createPullRequestsStub); }); + it('handles --skip-labeling', async () => { + await parser.parseAsync( + 'manifest-pr --repo-url=googleapis/release-please-cli --skip-labeling' + ); + + sinon.assert.calledOnceWithExactly(gitHubCreateStub, { + owner: 'googleapis', + repo: 'release-please-cli', + token: undefined, + }); + sinon.assert.calledOnceWithExactly( + fromManifestStub, + fakeGitHub, + 'main', + DEFAULT_RELEASE_PLEASE_CONFIG, + DEFAULT_RELEASE_PLEASE_MANIFEST, + sinon.match({skipLabeling: true}) + ); + sinon.assert.calledOnce(createPullRequestsStub); + }); + // it('handles --draft', async () => { // await parser.parseAsync( // 'manifest-pr --repo-url=googleapis/release-please-cli --draft'