worktree-flow 0.0.13 → 0.0.14

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.
@@ -1,7 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  import { createServices } from '../lib/services.js';
3
3
  import { createUseCases } from '../usecases/usecases.js';
4
- import { getStatusIndicator } from './helpers.js';
4
+ import { StatusService } from '../lib/status.js';
5
5
  export async function runList(useCases, services) {
6
6
  const { destPath, sourcePath } = services.config.getRequired();
7
7
  const config = services.config.load();
@@ -45,10 +45,25 @@ export async function runList(useCases, services) {
45
45
  // Re-print with full status information
46
46
  services.console.log(chalk.bold('\nWorkspaces:'));
47
47
  for (const workspace of result.workspaces) {
48
- const statusIndicator = getStatusIndicator(workspace);
49
48
  const activeIndicator = workspace.isActive ? chalk.green('* ') : ' ';
50
49
  const repoCount = chalk.dim(`(${workspace.repoCount} repo${workspace.repoCount === 1 ? '' : 's'})`);
51
- services.console.log(`${activeIndicator}${chalk.cyan(workspace.name)} ${repoCount} ${statusIndicator}`);
50
+ services.console.log(`${activeIndicator}${chalk.cyan(workspace.name)} ${repoCount}`);
51
+ // Load workspace config to get per-repo base branches
52
+ const workspaceConfig = services.workspaceConfig.load(workspace.path);
53
+ const getBaseBranch = (repoName) => workspaceConfig.baseBranches[repoName] || 'master';
54
+ // Display each repo with its status and tracking branch
55
+ for (const { repoName, status } of workspace.statuses) {
56
+ const baseBranch = getBaseBranch(repoName);
57
+ const statusMessage = StatusService.getStatusMessage(status, baseBranch);
58
+ const hasIssues = StatusService.hasIssues(status);
59
+ const indicator = hasIssues ? chalk.red('✗') : chalk.green('✓');
60
+ const message = hasIssues ? chalk.red(statusMessage) : chalk.green(statusMessage);
61
+ const trackingInfo = status.upstreamBranch
62
+ ? chalk.dim(` → ${status.upstreamBranch}`)
63
+ : chalk.dim(' (no upstream)');
64
+ services.console.log(` ${indicator} ${chalk.yellow(repoName)}: ${message}${trackingInfo}`);
65
+ }
66
+ services.console.log(''); // Blank line between workspaces
52
67
  }
53
68
  }
54
69
  export function registerListCommand(program) {
package/dist/lib/git.js CHANGED
@@ -45,7 +45,7 @@ export class GitService {
45
45
  return null;
46
46
  }
47
47
  async addWorktreeNewBranch(repoPath, worktreePath, branch, sourceBranch) {
48
- const args = ['worktree', 'add', '-b', branch, worktreePath];
48
+ const args = ['worktree', 'add', '--no-track', '-b', branch, worktreePath];
49
49
  if (sourceBranch) {
50
50
  args.push(sourceBranch);
51
51
  }
@@ -67,6 +67,15 @@ export class GitService {
67
67
  const output = await this.exec(worktreePath, ['rev-parse', '--abbrev-ref', 'HEAD']);
68
68
  return output.trim();
69
69
  }
70
+ async getUpstreamBranch(worktreePath) {
71
+ try {
72
+ const output = await this.exec(worktreePath, ['rev-parse', '--abbrev-ref', '@{u}']);
73
+ return output.trim();
74
+ }
75
+ catch {
76
+ return null;
77
+ }
78
+ }
70
79
  async hasUncommittedChanges(repoPath) {
71
80
  const output = await this.exec(repoPath, ['status', '--porcelain']);
72
81
  return output.length > 0;
@@ -8,17 +8,20 @@ export class StatusService {
8
8
  }
9
9
  async getWorktreeStatus(worktreePath, baseBranch) {
10
10
  try {
11
+ // Get branch information
12
+ const currentBranch = await this.git.getCurrentBranch(worktreePath);
13
+ const upstreamBranch = await this.git.getUpstreamBranch(worktreePath);
11
14
  // Check for uncommitted changes first
12
15
  const hasUncommitted = await this.git.hasUncommittedChanges(worktreePath);
13
16
  if (hasUncommitted) {
14
- return { type: 'uncommitted' };
17
+ return { type: 'uncommitted', currentBranch, upstreamBranch };
15
18
  }
16
19
  // Compare against base branch using git cherry (handles squash merges)
17
20
  const isAhead = await this.git.isAheadOfMain(worktreePath, baseBranch);
18
21
  if (isAhead) {
19
- return { type: 'ahead', comparedTo: 'main' };
22
+ return { type: 'ahead', comparedTo: 'main', currentBranch, upstreamBranch };
20
23
  }
21
- return { type: 'clean', comparedTo: 'main' };
24
+ return { type: 'clean', comparedTo: 'main', currentBranch, upstreamBranch };
22
25
  }
23
26
  catch (err) {
24
27
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worktree-flow",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Manage git worktrees across a poly-repo environment",
5
5
  "type": "module",
6
6
  "bin": {