MCPcopy Index your code
hub / github.com/21st-dev/1code / getTrackingBranchStatus

Function getTrackingBranchStatus

src/main/lib/git/status.ts:269–291  ·  view source on GitHub ↗
(
	git: ReturnType<typeof simpleGit>,
)

Source from the content-addressed store, hash-verified

267}
268
269async function getTrackingBranchStatus(
270 git: ReturnType<typeof simpleGit>,
271): Promise<TrackingStatus> {
272 try {
273 // Single git call - rev-list will fail if no upstream exists
274 // This is faster than checking upstream first, then counting
275 const tracking = await git.raw([
276 "rev-list",
277 "--left-right",
278 "--count",
279 "@{upstream}...HEAD",
280 ]);
281 const [pullStr, pushStr] = tracking.trim().split(/\s+/);
282 return {
283 pushCount: Number.parseInt(pushStr || "0", 10),
284 pullCount: Number.parseInt(pullStr || "0", 10),
285 hasUpstream: true,
286 };
287 } catch {
288 // No upstream branch configured
289 return { pushCount: 0, pullCount: 0, hasUpstream: false };
290 }
291}

Callers 1

createStatusRouterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected