MCPcopy Index your code
hub / github.com/desktop/desktop / getCurrentBranchForcePushState

Function getCurrentBranchForcePushState

app/src/lib/rebase.ts:39–68  ·  view source on GitHub ↗
(
  branchesState: IBranchesState,
  aheadBehind: IAheadBehind | null
)

Source from the content-addressed store, hash-verified

37 * branch should be a force push
38 */
39export function getCurrentBranchForcePushState(
40 branchesState: IBranchesState,
41 aheadBehind: IAheadBehind | null
42): ForcePushBranchState {
43 if (aheadBehind === null) {
44 // no tracking branch found
45 return ForcePushBranchState.NotAvailable
46 }
47
48 const { ahead, behind } = aheadBehind
49
50 if (behind === 0 || ahead === 0) {
51 // no a diverged branch to force push
52 return ForcePushBranchState.NotAvailable
53 }
54
55 const { tip, forcePushBranches } = branchesState
56
57 let canForcePushBranch = false
58 if (tip.kind === TipState.Valid) {
59 const localBranchName = tip.branch.nameWithoutRemote
60 const { sha } = tip.branch.tip
61 const foundEntry = forcePushBranches.get(localBranchName)
62 canForcePushBranch = foundEntry === sha
63 }
64
65 return canForcePushBranch
66 ? ForcePushBranchState.Recommended
67 : ForcePushBranchState.Available
68}

Callers 3

updateMenuItemLabelsMethod · 0.90
renderRemoteActionMethod · 0.90

Calls 1

getMethod · 0.45

Tested by

no test coverage detected