fix: avoid repeated macOS privacy prompts (#1524)
* fix: avoid repeated macos privacy prompts * fix: reduce background worktree permission probes * chore: pin oxlint for ci * fix: preserve optional rpc params with zod 4.4 * fix: preserve optional inline rpc params with zod 4.4
This commit is contained in:
+15
-2
@@ -23,6 +23,8 @@ const MAX_GIT_SHOW_BYTES = 10 * 1024 * 1024
|
||||
*/
|
||||
export async function getStatus(worktreePath: string): Promise<GitStatusResult> {
|
||||
const entries: GitStatusEntry[] = []
|
||||
let head: string | undefined
|
||||
let branch: string | undefined
|
||||
|
||||
// Why: detectConflictOperation (4 existsSync + readFile) and git status are
|
||||
// independent. Running them concurrently saves one round-trip of I/O latency.
|
||||
@@ -32,7 +34,7 @@ export async function getStatus(worktreePath: string): Promise<GitStatusResult>
|
||||
// in double quotes. Without it, the parsed entry.path is unreadable in the
|
||||
// sidebar and downstream `git show :"docs/\346..."` lookups silently miss.
|
||||
const statusPromise = gitExecFileAsync(
|
||||
['-c', 'core.quotePath=false', 'status', '--porcelain=v2', '--untracked-files=all'],
|
||||
['-c', 'core.quotePath=false', 'status', '--porcelain=v2', '--branch', '--untracked-files=all'],
|
||||
{ cwd: worktreePath }
|
||||
)
|
||||
const conflictOperation = await conflictPromise
|
||||
@@ -47,6 +49,17 @@ export async function getStatus(worktreePath: string): Promise<GitStatusResult>
|
||||
continue
|
||||
}
|
||||
|
||||
if (line.startsWith('# branch.oid ')) {
|
||||
head = line.slice('# branch.oid '.length).trim()
|
||||
continue
|
||||
}
|
||||
|
||||
if (line.startsWith('# branch.head ')) {
|
||||
const branchHead = line.slice('# branch.head '.length).trim()
|
||||
branch = branchHead && branchHead !== '(detached)' ? `refs/heads/${branchHead}` : ''
|
||||
continue
|
||||
}
|
||||
|
||||
if (line.startsWith('1 ') || line.startsWith('2 ')) {
|
||||
// Changed entries: "1 XY sub mH mI mW hH path" or "2 XY sub mH mI mW hH X\tscore\tpath\torigPath"
|
||||
const parts = line.split(' ')
|
||||
@@ -95,7 +108,7 @@ export async function getStatus(worktreePath: string): Promise<GitStatusResult>
|
||||
// Not a git repo or git not available
|
||||
}
|
||||
|
||||
return { entries, conflictOperation }
|
||||
return { entries, conflictOperation, head, branch }
|
||||
}
|
||||
|
||||
function parseStatusChar(char: string): GitFileStatus {
|
||||
|
||||
Reference in New Issue
Block a user