Skip to content

Commit a0c7d17

Browse files
feat: add option to skip pushing to remote (#172)
Co-authored-by: Dominic Griesel <[email protected]>
1 parent 4da181d commit a0c7d17

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Placeholder for the next version (at the beginning of the line):
44
## **WORK IN PROGRESS**
55
-->
6+
## **WORK IN PROGRESS**
7+
* `git` plugin: allow to skip push stage via `noPush` option
8+
69
## 3.7.3 (2024-07-05)
710
* `package` plugin: Support monorepos managed with Yarn v4
811

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@ When this option is set, only the annotated release tag will be pushed to the re
334334
npm run release patch -- --tagOnly
335335
```
336336
337+
#### Do not push to the remote at all (`--noPush`)
338+
339+
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.
340+
341+
```bash
342+
npm run release patch -- --noPush
343+
```
344+
337345
### `changelog` plugin options
338346
339347
#### Limit the number of entries in README.md (`--numChangelogEntries` or `-n`)

packages/plugin-git/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ class GitPlugin implements Plugin {
9898
description: "Only push the annotated tag, not the release commit",
9999
default: false,
100100
},
101+
noPush: {
102+
type: "boolean",
103+
description: "Do not push anything to the remote",
104+
default: false,
105+
},
101106
});
102107
}
103108

@@ -183,6 +188,11 @@ ${context.getData("changelog_new")}`;
183188
}
184189

185190
private async executePushStage(context: Context): Promise<void> {
191+
if (context.argv.noPush) {
192+
context.cli.log("git push skipped");
193+
return;
194+
}
195+
186196
const upstream =
187197
(context.argv.remote as string | undefined) || (await getUpstream(context));
188198
const [remote, branch] = upstream.split("/", 2);

packages/release-script/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ class CLI implements ICLI {
8989
this.log(`$ ${command}`);
9090
}
9191
clearLines(lines: number): void {
92+
if (!process.stdout.isTTY) {
93+
return;
94+
}
95+
9296
process.stdout.moveCursor(0, -lines);
9397
process.stdout.clearScreenDown();
9498
}

0 commit comments

Comments
 (0)