Files
orca/src/shared/source-control/dropdown/source-control-dropdown-labels.ts
T

63 lines
2.1 KiB
TypeScript

export function describePushCount(ahead: number): string {
return `Push ${ahead} commit${ahead === 1 ? '' : 's'}`
}
export function describePullCount(behind: number): string {
return `Pull ${behind} commit${behind === 1 ? '' : 's'}`
}
export function describeFastForwardCount(behind: number): string {
return `Fast-forward ${behind} commit${behind === 1 ? '' : 's'}`
}
export function describeSyncCounts(ahead: number, behind: number): string {
return `Pull ${behind}, push ${ahead}`
}
export function formatAheadStatus(ahead: number): string {
return `↑${ahead}`
}
export function formatBehindStatus(behind: number): string {
return `↓${behind}`
}
export function formatSyncStatus(ahead: number, behind: number): string {
return `↓${behind} ↑${ahead}`
}
export function formatForcePushTitle(
branchCommitsAhead: number | undefined,
upstreamName?: string
): string {
const countText =
branchCommitsAhead && branchCommitsAhead > 0
? `${branchCommitsAhead} branch commit${branchCommitsAhead === 1 ? '' : 's'}`
: 'this branch'
return `Remote only has older copies of local commits. Force push ${countText} with lease to update ${upstreamName ?? 'the remote branch'}.`
}
export function formatManualForcePushTitle(
ahead: number,
behind: number,
upstreamName?: string
): string {
const commitText = ahead === 1 ? '1 local commit' : `${ahead} local commits`
if (behind > 0) {
return `Force push ${commitText} with lease to update ${upstreamName ?? 'the remote branch'} and replace remote-only commits.`
}
return `Force push ${commitText} with lease to update ${upstreamName ?? 'the remote branch'}.`
}
export function formatUnpublishedForcePushTitle(branchCommitsAhead: number | undefined): string {
const countText =
branchCommitsAhead && branchCommitsAhead > 0
? `${branchCommitsAhead} branch commit${branchCommitsAhead === 1 ? '' : 's'}`
: 'this branch'
return `Force push ${countText} with lease and set an upstream if needed.`
}
export function formatRebaseBaseRef(baseRef: string): string {
return baseRef.replace(/^refs\/remotes\//, '').replace(/^remotes\//, '')
}