mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-30 11:53:55 +01:00
Approved edits after review no longer force a new full review, and ship works in git worktrees (#4862)
Small edits that a project lead approves after the final review no longer force a whole new review. Shipping from a git worktree no longer crashes, and merging main no longer throws away a finished review when main already made one of the PR's exact changes. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/specialist-batched#2 reader=testing
This commit is contained in:
1 parent
9befb56288
commit
d0b59828d6
21 files changed
+582
-66
No files matched your search
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Where a gstack file under this checkout's git directory lives: `git rev-parse --git-path <name>` (HARN-108). In a linked
|
||||
* worktree `.git` is a file (`gitdir: …`), so the literal `.git/<name>` every caller fell back to when git failed, timed out
|
||||
* or printed nothing wrote through a file and failed with ENOTDIR. A failed or empty answer is now an error the caller names.
|
||||
*/
|
||||
import * as path from 'node:path';
|
||||
import { spawnSync } from './spawn-sync';
|
||||
|
||||
export type GitPath = { ok: true; path: string } | { ok: false; error: string };
|
||||
|
||||
export function gitPath(cwd: string, name: string, timeoutMs = 30_000): GitPath {
|
||||
const r = spawnSync('git', ['rev-parse', '--git-path', name], { cwd, encoding: 'utf8', timeout: Math.max(1, timeoutMs) });
|
||||
const out = r.status === 0 ? String(r.stdout ?? '').trim() : '';
|
||||
if (out) return { ok: true, path: path.resolve(cwd, out) };
|
||||
const why = String(r.stderr ?? '').trim().split('\n')[0] || (r.error as NodeJS.ErrnoException | undefined)?.code || (r.signal ? `killed by ${r.signal}` : `exit ${r.status}`);
|
||||
return { ok: false, error: `git rev-parse --git-path ${name} gave no path (${why.slice(0, 200)}), and gstack does not guess .git/${name}: in a linked worktree .git is a file` };
|
||||
}
|
||||
Reference in new issue
Block a user