MCPcopy
hub / github.com/desktop/desktop / getStatus

Function getStatus

app/src/lib/git/status.ts:207–288  ·  view source on GitHub ↗
(
  repository: Repository,
  includeUntracked = true,
  rejectOnError = false
)

Source from the content-addressed store, hash-verified

205 rejectOnError: false
206): Promise<IStatusResult | null>
207export async function getStatus(
208 repository: Repository,
209 includeUntracked = true,
210 rejectOnError = false
211): Promise<IStatusResult | null> {
212 const args = [
213 '--no-optional-locks',
214 'status',
215 ...(includeUntracked ? ['--untracked-files=all'] : []),
216 '--branch',
217 '--porcelain=2',
218 '-z',
219 ]
220
221 const { stdout, exitCode } = await git(args, repository.path, 'getStatus', {
222 successExitCodes: new Set(rejectOnError ? [0] : [0, 128]),
223 encoding: 'buffer',
224 })
225
226 if (exitCode === 128) {
227 log.debug(
228 `'git status' returned 128 for '${repository.path}' and is likely missing its .git directory`
229 )
230 return null
231 }
232
233 const parsed = parsePorcelainStatus(stdout)
234 const headers = parsed.filter(isStatusHeader)
235 const entries = parsed.filter(isStatusEntry)
236
237 const mergeHeadFound = await isMergeHeadSet(repository)
238 const conflictedFilesInIndex = entries.filter(e =>
239 conflictStatusCodes.includes(e.statusCode)
240 )
241 const rebaseInternalState = await getRebaseInternalState(repository)
242
243 const conflictDetails = await getConflictDetails(
244 repository,
245 mergeHeadFound,
246 conflictedFilesInIndex,
247 rebaseInternalState
248 )
249
250 // Map of files keyed on their paths.
251 const files = entries.reduce(
252 (files, entry) => buildStatusMap(files, entry, conflictDetails),
253 new Map<string, WorkingDirectoryFileChange>()
254 )
255
256 const {
257 currentBranch,
258 currentUpstreamBranch,
259 currentTip,
260 branchAheadBehind,
261 } = headers.reduce(parseStatusHeader, {
262 currentBranch: undefined,
263 currentUpstreamBranch: undefined,
264 currentTip: undefined,

Callers 9

getStatusOrThrowFunction · 0.90
init-test.tsFile · 0.90
status-test.tsFile · 0.90
resolveAndContinueFunction · 0.90
undoFirstCommitMethod · 0.90
loadStatusMethod · 0.90
continueCherryPickFunction · 0.90
continueRebaseFunction · 0.90
CreateRepositoryClass · 0.90

Calls 11

parsePorcelainStatusFunction · 0.90
isMergeHeadSetFunction · 0.90
getRebaseInternalStateFunction · 0.90
isCherryPickHeadFoundFunction · 0.90
isSquashMsgSetFunction · 0.90
getConflictDetailsFunction · 0.85
buildStatusMapFunction · 0.85
debugMethod · 0.80
fromFilesMethod · 0.80
gitFunction · 0.70
filterMethod · 0.65

Tested by

no test coverage detected