@lakakala/kgit 0.3.0 → 0.3.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.
@@ -0,0 +1 @@
1
+ export declare function cdCommand(workspace: string, project?: string): void;
@@ -0,0 +1,14 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ import { loadConfig } from '../config.js';
4
+ export function cdCommand(workspace, project) {
5
+ const config = loadConfig();
6
+ const targetPath = project
7
+ ? path.join(config.workspace, workspace, project)
8
+ : path.join(config.workspace, workspace);
9
+ if (!fs.existsSync(targetPath)) {
10
+ process.stderr.write(`Error: path does not exist: ${targetPath}\n`);
11
+ process.exit(1);
12
+ }
13
+ process.stdout.write(targetPath);
14
+ }
package/dist/git.js CHANGED
@@ -7,9 +7,11 @@ async function localBranchExists(repoPath, branch) {
7
7
  }
8
8
  async function remoteBranchExists(repoPath, branch) {
9
9
  try {
10
- const { stdout } = await execa('git', ['-C', repoPath, 'branch', '-r', '--list', `*/${branch}`], { stdio: 'pipe' });
11
- const match = stdout.trim().split('\n').find(l => l.trim().length > 0);
12
- return match ? match.trim() : null;
10
+ // Query remote directly more reliable than local cached refs
11
+ const { stdout } = await execa('git', ['-C', repoPath, 'ls-remote', '--heads', 'origin', branch], { stdio: 'pipe' });
12
+ if (stdout.trim().length === 0)
13
+ return null;
14
+ return `origin/${branch}`;
13
15
  }
14
16
  catch {
15
17
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lakakala/kgit",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Git worktree workspace manager",
5
5
  "type": "module",
6
6
  "bin": {