Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/services/skills/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,20 @@ export function registerSkillsCommands(program: Command): void {
try {
execFileSync('git', cloneArgs, { stdio: ['inherit', 'inherit', 'pipe'] });
} catch (e: unknown) {
const msg = e instanceof Error ? e.message : String(e);
throw new Error(msg.replace(/x-(?:token-auth|access-token):[^@]+@/g, 'x-token-auth:***@'));
// On some platforms (e.g. Windows with Git Credential Manager), git may
// write authentication warnings to stderr and exit non-zero even though
// the clone was successfully written to disk. Verify by running
// `git rev-parse HEAD` at the destination; if that succeeds the repo is
// valid and we continue rather than surfacing a spurious error.
let cloneActuallySucceeded = false;
try {
execFileSync('git', ['-C', resolvedPath, 'rev-parse', 'HEAD'], { stdio: 'pipe' });
cloneActuallySucceeded = true;
} catch { /* repo not valid — fall through and re-throw original error */ }
if (!cloneActuallySucceeded) {
const msg = e instanceof Error ? e.message : String(e);
throw new Error(msg.replace(/x-(?:token-auth|access-token):[^@]+@/g, 'x-token-auth:***@'));
}
Comment on lines +271 to +279

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean flag can be eliminated — re-throw inside the inner catch instead:

Suggested change
let cloneActuallySucceeded = false;
try {
execFileSync('git', ['-C', resolvedPath, 'rev-parse', 'HEAD'], { stdio: 'pipe' });
cloneActuallySucceeded = true;
} catch { /* repo not valid — fall through and re-throw original error */ }
if (!cloneActuallySucceeded) {
const msg = e instanceof Error ? e.message : String(e);
throw new Error(msg.replace(/x-(?:token-auth|access-token):[^@]+@/g, 'x-token-auth:***@'));
}
try {
execFileSync('git', ['-C', resolvedPath, 'rev-parse', 'HEAD'], { stdio: 'pipe' });
} catch {
// rev-parse failed — repo is not valid, surface the original clone error
const msg = e instanceof Error ? e.message : String(e);
throw new Error(msg.replace(/x-(?:token-auth|access-token):[^@]+@/g, 'x-token-auth:***@'));
}

Same semantics, one less variable, easier to read at a glance.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude[agent] fix this

}
}

Expand Down
Loading