Skip to content

Commit 9b87c2c

Browse files
committed
Add confirmation step
1 parent 6075459 commit 9b87c2c

File tree

5 files changed

+1081
-5
lines changed

5 files changed

+1081
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ Run with the `--verbose` flag to see debug information
5555
| --skip-forks | Skips forked repositories | false |
5656
| --old | The name of the branch to rename | master |
5757
| --new | The new branch name | main |
58+
| --confirm | Run without prompting for confirmation | false |

bin/github-default-branch

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,21 @@
3333

3434
const { Octokit } = require("@octokit/rest");
3535

36+
const confirmation = require("../src/confirmation");
3637
const getRepos = require("../src/get-repos");
3738
const getBranchSha = require("../src/get-branch-sha");
3839
const createBranch = require("../src/create-branch");
3940
const removeBranch = require("../src/remove-branch");
4041
const updateContent = require("../src/update-content");
4142

43+
const old = argv.old || "master";
44+
const target = argv.new || "main";
45+
46+
// Make sure they want to do this
47+
if (!(await confirmation(argv.confirm, old, target))) {
48+
return;
49+
}
50+
4251
const octokit = new Octokit({
4352
auth: argv.pat || process.env.GITHUB_TOKEN,
4453
});
@@ -58,10 +67,6 @@
5867
console.log(repos.join("\n"));
5968
return;
6069
}
61-
62-
const old = argv.old || "master";
63-
const target = argv.new || "main";
64-
6570
for (let r of repos) {
6671
if (argv.verbose) {
6772
console.log(`✏️ Processing ${r}`);

0 commit comments

Comments
 (0)