refactor(git): split status.ts into source-control modules (#16393)

This commit is contained in:
Neil
2026-08-25 02:24:11 -07:00
committed by GitHub
parent 127fa7fae0
commit 33587fb77d
34 changed files with 2587 additions and 2363 deletions
@@ -0,0 +1,51 @@
import type { GitRuntimeOptions } from '../git-runtime-options'
import { gitOptionsForWorktree } from '../git-runtime-options'
import { gitExecFileAsync, gitOptionalLocksDisabledEnv } from '../runner'
export async function readGitlinkOidFromTree(
worktreePath: string,
ref: string,
submodulePath: string,
options: GitRuntimeOptions
): Promise<string> {
try {
const { stdout } = await gitExecFileAsync(['ls-tree', ref, '--', submodulePath], {
...gitOptionsForWorktree(worktreePath, options),
env: gitOptionalLocksDisabledEnv()
})
return stdout.match(/^160000 commit ([0-9a-f]+)\t/m)?.[1] ?? ''
} catch {
return ''
}
}
export async function readGitlinkOidFromIndex(
worktreePath: string,
submodulePath: string,
options: GitRuntimeOptions
): Promise<string> {
try {
const { stdout } = await gitExecFileAsync(['ls-files', '-s', '--', submodulePath], {
...gitOptionsForWorktree(worktreePath, options),
env: gitOptionalLocksDisabledEnv()
})
return stdout.match(/^160000 ([0-9a-f]+) /m)?.[1] ?? ''
} catch {
return ''
}
}
export async function readWorkingSubmoduleHead(
submoduleWorktreePath: string,
options: GitRuntimeOptions
): Promise<string> {
try {
const { stdout } = await gitExecFileAsync(['rev-parse', 'HEAD'], {
...gitOptionsForWorktree(submoduleWorktreePath, options),
env: gitOptionalLocksDisabledEnv()
})
return stdout.trim()
} catch {
return ''
}
}