fix: allow git checkout with uncommitted files (#945)
This commit is contained in:
@@ -1057,10 +1057,6 @@ export const GitView: React.FC = () => {
|
||||
}, [currentDirectory, selectedPaths, settingsGitmojiEnabled, gitmojiEmojis, scrollActionPanelToBottom]);
|
||||
|
||||
const formatBlockingReason = (reason: ReturnType<typeof getMutationBlockingReasons>[number]): string => {
|
||||
if (reason.reason === 'dirty') {
|
||||
const count = typeof reason.dirtyFiles === 'number' ? reason.dirtyFiles : null;
|
||||
return count != null ? `${count} uncommitted file${count === 1 ? '' : 's'}` : 'uncommitted changes';
|
||||
}
|
||||
if (reason.reason === 'attention') {
|
||||
return `${reason.attentionReason} in progress`;
|
||||
}
|
||||
@@ -1073,7 +1069,7 @@ export const GitView: React.FC = () => {
|
||||
const handleCreateBranch = async (branchName: string, remote?: GitRemote) => {
|
||||
if (!currentDirectory || !status) return;
|
||||
|
||||
const blockingReasons = getMutationBlockingReasons(worktreeAttachment ?? null, status);
|
||||
const blockingReasons = getMutationBlockingReasons(worktreeAttachment);
|
||||
if (blockingReasons.length > 0) {
|
||||
toast.error(`Cannot create branch: ${formatBlockingReason(blockingReasons[0])}`);
|
||||
return;
|
||||
@@ -1127,7 +1123,7 @@ export const GitView: React.FC = () => {
|
||||
const handleRenameBranch = async (oldName: string, newName: string) => {
|
||||
if (!currentDirectory) return;
|
||||
|
||||
const blockingReasons = getMutationBlockingReasons(worktreeAttachment ?? null, status);
|
||||
const blockingReasons = getMutationBlockingReasons(worktreeAttachment);
|
||||
if (blockingReasons.length > 0) {
|
||||
toast.error(`Cannot rename branch: ${formatBlockingReason(blockingReasons[0])}`);
|
||||
return;
|
||||
@@ -1149,7 +1145,7 @@ export const GitView: React.FC = () => {
|
||||
if (!currentDirectory) return;
|
||||
|
||||
// Block mutation if worktree is in an attention-required state
|
||||
const blockingReasons = getMutationBlockingReasons(worktreeAttachment ?? null, status);
|
||||
const blockingReasons = getMutationBlockingReasons(worktreeAttachment);
|
||||
if (blockingReasons.length > 0) {
|
||||
toast.error(`Cannot checkout: ${formatBlockingReason(blockingReasons[0])}`);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user