@sven1103/opencode-worktree-workflow 0.5.0 → 0.5.1

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/package.json +1 -1
  2. package/src/index.js +14 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sven1103/opencode-worktree-workflow",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "OpenCode plugin for creating and cleaning up git worktrees.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -465,6 +465,18 @@ export const WorktreeWorkflowPlugin = async ({ $, directory }) => {
465
465
  return remoteExists.exitCode === 0 ? `${remote}/${baseBranch}` : baseBranch;
466
466
  }
467
467
 
468
+ async function resolveBaseTarget(repoRoot, config) {
469
+ const defaultBranch = await getDefaultBranch(repoRoot, config.remote);
470
+ const baseBranch = await resolveBaseBranch(repoRoot, config.remote, config.baseBranch);
471
+ const baseRef = await getBaseRef(repoRoot, config.remote, baseBranch);
472
+
473
+ return {
474
+ defaultBranch,
475
+ baseBranch,
476
+ baseRef,
477
+ };
478
+ }
479
+
468
480
  async function ensureBranchDoesNotExist(repoRoot, branchName) {
469
481
  const exists = await git(["show-ref", "--verify", "--quiet", `refs/heads/${branchName}`], {
470
482
  cwd: repoRoot,
@@ -488,9 +500,7 @@ export const WorktreeWorkflowPlugin = async ({ $, directory }) => {
488
500
 
489
501
  const repoRoot = await getRepoRoot();
490
502
  const config = await loadWorkflowConfig(repoRoot);
491
- const defaultBranch = await getDefaultBranch(repoRoot, config.remote);
492
- const baseBranch = await resolveBaseBranch(repoRoot, config.remote, config.baseBranch);
493
- const baseRef = await getBaseRef(repoRoot, config.remote, baseBranch);
503
+ const { defaultBranch, baseBranch, baseRef } = await resolveBaseTarget(repoRoot, config);
494
504
  const baseCommit = (await git(["rev-parse", baseRef], { cwd: repoRoot })).stdout;
495
505
  const slug = slugifyTitle(args.title);
496
506
 
@@ -547,9 +557,7 @@ export const WorktreeWorkflowPlugin = async ({ $, directory }) => {
547
557
 
548
558
  context.metadata({ title: `Clean worktrees (${normalizedArgs.mode})` });
549
559
 
550
- const defaultBranch = await getDefaultBranch(repoRoot, config.remote);
551
- const baseBranch = await resolveBaseBranch(repoRoot, config.remote, config.baseBranch);
552
- const baseRef = await getBaseRef(repoRoot, config.remote, baseBranch);
560
+ const { defaultBranch, baseBranch, baseRef } = await resolveBaseTarget(repoRoot, config);
553
561
  const activeWorktree = path.resolve(context.worktree || repoRoot);
554
562
  const worktreeList = await git(["worktree", "list", "--porcelain"], { cwd: repoRoot });
555
563
  const entries = parseWorktreeList(worktreeList.stdout);