Git errors carry git's own message
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RNwtXPYqFu3oKaaXwYwNWW
This commit is contained in:
parent
033427c99b
commit
97d3d65364
1 changed files with 8 additions and 1 deletions
|
|
@ -12,7 +12,14 @@ export class Repo {
|
|||
}
|
||||
|
||||
git(args, opts = {}) {
|
||||
return execFileSync('git', args, { cwd: this.dir, encoding: opts.encoding ?? 'utf8', maxBuffer: 64 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], input: opts.input });
|
||||
try {
|
||||
return execFileSync('git', args, { cwd: this.dir, encoding: opts.encoding ?? 'utf8', maxBuffer: 64 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe'], input: opts.input });
|
||||
} catch (e) {
|
||||
// git's own explanation, not just "Command failed".
|
||||
const why = `${e.stderr ?? ''}${e.stdout ?? ''}`.trim();
|
||||
if (why) e.message = `git ${args.find((a) => !a.startsWith('-') && !a.includes('=')) ?? ''} failed: ${why.slice(0, 2000)}`;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
head() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue