Skip to content

Commit dd65b9c

Browse files
Feat: Add an option to Don't push when there are multiple git remotes (#434)
* feat(commit.ts): add option to skip pushing commits to a remote repository to enhance user flexibility during commit process * Update src/commands/commit.ts --------- Co-authored-by: GPT8 <[email protected]>
1 parent 6b822eb commit dd65b9c

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/commands/commit.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,26 +148,29 @@ ${chalk.grey('——————————————————')}`
148148
process.exit(0);
149149
}
150150
} else {
151+
const skipOption = `don't push`
151152
const selectedRemote = (await select({
152153
message: 'Choose a remote to push to',
153-
options: remotes.map((remote) => ({ value: remote, label: remote }))
154+
options: [...remotes, skipOption].map((remote) => ({ value: remote, label: remote })),
154155
})) as string;
155156

156157
if (isCancel(selectedRemote)) process.exit(1);
157158

158-
const pushSpinner = spinner();
159-
160-
pushSpinner.start(`Running 'git push ${selectedRemote}'`);
161-
162-
const { stdout } = await execa('git', ['push', selectedRemote]);
163-
164-
if (stdout) outro(stdout);
165-
166-
pushSpinner.stop(
167-
`${chalk.green(
168-
'✔'
169-
)} successfully pushed all commits to ${selectedRemote}`
170-
);
159+
if (selectedRemote !== skipOption) {
160+
const pushSpinner = spinner();
161+
162+
pushSpinner.start(`Running 'git push ${selectedRemote}'`);
163+
164+
const { stdout } = await execa('git', ['push', selectedRemote]);
165+
166+
if (stdout) outro(stdout);
167+
168+
pushSpinner.stop(
169+
`${chalk.green(
170+
'✔'
171+
)} successfully pushed all commits to ${selectedRemote}`
172+
);
173+
}
171174
}
172175
} else {
173176
const regenerateMessage = await confirm({

0 commit comments

Comments
 (0)