From a0c7d17fb8962af88947d29eb63b89ab0b98dd2e Mon Sep 17 00:00:00 2001 From: Max Hauser Date: Tue, 23 Jul 2024 14:16:50 +0200 Subject: [PATCH] feat: add option to skip pushing to remote (#172) Co-authored-by: Dominic Griesel --- CHANGELOG.md | 3 +++ README.md | 8 ++++++++ packages/plugin-git/src/index.ts | 10 ++++++++++ packages/release-script/src/index.ts | 4 ++++ 4 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 851e0d7..e5b3d3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ Placeholder for the next version (at the beginning of the line): ## **WORK IN PROGRESS** --> +## **WORK IN PROGRESS** +* `git` plugin: allow to skip push stage via `noPush` option + ## 3.7.3 (2024-07-05) * `package` plugin: Support monorepos managed with Yarn v4 diff --git a/README.md b/README.md index 2d546b7..b5f8773 100644 --- a/README.md +++ b/README.md @@ -334,6 +334,14 @@ When this option is set, only the annotated release tag will be pushed to the re npm run release patch -- --tagOnly ``` +#### Do not push to the remote at all (`--noPush`) + +When this option is set, nothing will be pushed to the remote. This option can be useful if branch protection rules prevent the release branch from being pushed, and release commits are pushed by other means. + +```bash +npm run release patch -- --noPush +``` + ### `changelog` plugin options #### Limit the number of entries in README.md (`--numChangelogEntries` or `-n`) diff --git a/packages/plugin-git/src/index.ts b/packages/plugin-git/src/index.ts index 4010bd1..be56f32 100644 --- a/packages/plugin-git/src/index.ts +++ b/packages/plugin-git/src/index.ts @@ -98,6 +98,11 @@ class GitPlugin implements Plugin { description: "Only push the annotated tag, not the release commit", default: false, }, + noPush: { + type: "boolean", + description: "Do not push anything to the remote", + default: false, + }, }); } @@ -183,6 +188,11 @@ ${context.getData("changelog_new")}`; } private async executePushStage(context: Context): Promise { + if (context.argv.noPush) { + context.cli.log("git push skipped"); + return; + } + const upstream = (context.argv.remote as string | undefined) || (await getUpstream(context)); const [remote, branch] = upstream.split("/", 2); diff --git a/packages/release-script/src/index.ts b/packages/release-script/src/index.ts index e2e2ac6..2fe2f42 100644 --- a/packages/release-script/src/index.ts +++ b/packages/release-script/src/index.ts @@ -89,6 +89,10 @@ class CLI implements ICLI { this.log(`$ ${command}`); } clearLines(lines: number): void { + if (!process.stdout.isTTY) { + return; + } + process.stdout.moveCursor(0, -lines); process.stdout.clearScreenDown(); }