mirror of
https://github.com/stablyai/orca.git
synced 2026-09-23 00:02:29 +00:00
32 lines
722 B
TypeScript
32 lines
722 B
TypeScript
type GitStatusLineStatEntry = {
|
|
area?: unknown
|
|
path?: unknown
|
|
}
|
|
|
|
export type GitStatusLineStatInputs = {
|
|
hasStaged: boolean
|
|
hasUnstaged: boolean
|
|
untrackedPaths: string[]
|
|
}
|
|
|
|
export function collectGitStatusLineStatInputs(
|
|
entries: readonly GitStatusLineStatEntry[]
|
|
): GitStatusLineStatInputs {
|
|
let hasStaged = false
|
|
let hasUnstaged = false
|
|
const untrackedPaths: string[] = []
|
|
|
|
for (const entry of entries) {
|
|
const area = entry.area
|
|
if (area === 'staged') {
|
|
hasStaged = true
|
|
} else if (area === 'unstaged') {
|
|
hasUnstaged = true
|
|
} else if (area === 'untracked') {
|
|
untrackedPaths.push(entry.path as string)
|
|
}
|
|
}
|
|
|
|
return { hasStaged, hasUnstaged, untrackedPaths }
|
|
}
|