@biffo/cli 0.60.2 → 0.60.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +16 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -581,6 +581,18 @@ var GitHubAdapter = class {
581
581
  * `biffo core upgrade --apply` (ADR-0006 Phase 3b) to propose a core upgrade
582
582
  * as a reviewable PR rather than pushing to a protected branch.
583
583
  */
584
+ /**
585
+ * The repo's default branch — the integration branch a PR should target.
586
+ *
587
+ * Asked of GitHub rather than inferred from the local checkout: it differs per
588
+ * repo (biffo-template uses `main`, instances use `dev`), and the local
589
+ * current branch is whatever the caller happens to be on, which under the
590
+ * worktree-per-change workflow is never it.
591
+ */
592
+ async defaultBranch(args) {
593
+ const { data } = await this.octokit.repos.get({ owner: args.owner, repo: args.repo });
594
+ return data.default_branch;
595
+ }
584
596
  async createPullRequest(args) {
585
597
  const { data } = await this.octokit.pulls.create({
586
598
  owner: args.owner,
@@ -1990,7 +2002,7 @@ var coreUpgradeCommand = new Command3("upgrade").description("Three-way-merge te
1990
2002
  ).option("--apply", "Apply the plan on a new branch and open a PR (default: dry run)").option("--allow-conflicts", "With --apply, open the PR even if some files conflict").option(
1991
2003
  "--acknowledge-breaking",
1992
2004
  "With --apply, proceed even though this upgrade crosses a documented breaking change"
1993
- ).option("--base <branch>", "Base branch for the PR (defaults to the current branch)").option("--remote <name>", "Git remote to push to and open the PR on (default: origin)").action(
2005
+ ).option("--base <branch>", "Base branch for the PR (defaults to the repo\u2019s default branch)").option("--remote <name>", "Git remote to push to and open the PR on (default: origin)").action(
1994
2006
  async (options) => {
1995
2007
  const cwd = options.cwd ? resolve3(options.cwd) : process.cwd();
1996
2008
  const runOptions = {
@@ -2143,7 +2155,6 @@ async function applyAndOpenPr(options, deps, plan, migrations, fromVersion, toVe
2143
2155
  if (await git.hasUncommittedChanges(options.cwd)) {
2144
2156
  throw new Error("The working tree has uncommitted changes. Commit or stash them first.");
2145
2157
  }
2146
- const base = options.base ?? await git.currentBranch(options.cwd);
2147
2158
  const branch = upgradeBranchName(fromVersion, toVersion);
2148
2159
  log.step(1, 4, `Creating branch ${branch}`);
2149
2160
  await git.createBranch(options.cwd, branch);
@@ -2165,7 +2176,9 @@ async function applyAndOpenPr(options, deps, plan, migrations, fromVersion, toVe
2165
2176
  log.step(4, 4, "Opening pull request");
2166
2177
  const remoteUrl = await git.getRemoteUrl(options.cwd, options.remote);
2167
2178
  const { owner, repo } = parseGitHubRepo(remoteUrl);
2168
- const pr = await deps.makeGitHub(token).createPullRequest({
2179
+ const github = deps.makeGitHub(token);
2180
+ const base = options.base ?? await github.defaultBranch({ owner, repo });
2181
+ const pr = await github.createPullRequest({
2169
2182
  owner,
2170
2183
  repo,
2171
2184
  head: branch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.60.2",
3
+ "version": "0.60.4",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",