mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* fix(mobile): build the Source Control action sheet from desktop's menu rows Adds Force Push and desktop's order, enable rules and hints. * fix(mobile): rebase from desktop's effective base and keep the Force Push warning in the action sheet * fix(mobile): keep the rebase row's base when the branch compare fails * fix(mobile): keep upstream compares working when the default base lookup fails * fix(mobile): keep the rebase target apart from the branch compare so failed or unsupported compares keep it * fix(mobile): leave force pushes to desktop when the linked review has its own push target * refactor(mobile): rebase onto the shown base and share the force-push block with the primary action
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
export const COMMIT_MESSAGE_REQUIRED_REASON = 'Enter a commit message to commit' as const
|
|
|
|
export type CommitEligibilityInputs = {
|
|
stagedCount: number
|
|
hasPartiallyStagedChanges: boolean
|
|
hasMessage: boolean
|
|
hasUnresolvedConflicts: boolean
|
|
isCommitting: boolean
|
|
isRemoteOperationActive: boolean
|
|
isPullRequestOperationActive?: boolean
|
|
}
|
|
|
|
export function resolveCommitDisabledReason(
|
|
inputs: Pick<
|
|
CommitEligibilityInputs,
|
|
'stagedCount' | 'hasPartiallyStagedChanges' | 'hasMessage' | 'hasUnresolvedConflicts'
|
|
>
|
|
): string | null {
|
|
if (inputs.hasUnresolvedConflicts) {
|
|
return 'Resolve conflicts before committing'
|
|
}
|
|
if (inputs.stagedCount === 0) {
|
|
return 'Stage at least one file to commit'
|
|
}
|
|
if (!inputs.hasMessage) {
|
|
return COMMIT_MESSAGE_REQUIRED_REASON
|
|
}
|
|
return null
|
|
}
|
|
|
|
function isCommitGloballyBusy(inputs: CommitEligibilityInputs): boolean {
|
|
return (
|
|
inputs.isCommitting ||
|
|
inputs.isRemoteOperationActive ||
|
|
(inputs.isPullRequestOperationActive ?? false)
|
|
)
|
|
}
|
|
|
|
export function canSubmitCommit(inputs: CommitEligibilityInputs): boolean {
|
|
return !isCommitGloballyBusy(inputs) && resolveCommitDisabledReason(inputs) === null
|
|
}
|
|
|
|
// Allow typing through the empty-message blocker; other commit blockers and in-flight work lock editing.
|
|
export function isCommitMessageFieldDisabled(inputs: CommitEligibilityInputs): boolean {
|
|
if (isCommitGloballyBusy(inputs)) {
|
|
return true
|
|
}
|
|
const commitDisabledReason = resolveCommitDisabledReason(inputs)
|
|
return commitDisabledReason !== null && commitDisabledReason !== COMMIT_MESSAGE_REQUIRED_REASON
|
|
}
|