| ... | ... | @@ -4,6 +4,7 @@ import { useCallback, useMemo, useState } from "react"; |
| 4 | 4 | import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react"; |
| 5 | 5 | import { GitHubIcon } from "./Icons"; |
| 6 | 6 | import { |
| 7 | buildGitActionProgressStages, |
| 7 | 8 | buildMenuItems, |
| 8 | 9 | type GitActionIconName, |
| 9 | 10 | type GitActionMenuItem, |
| ... | ... | @@ -134,26 +135,6 @@ function GitQuickActionIcon({ quickAction }: { quickAction: GitQuickAction }) { |
| 134 | 135 | return <InfoIcon className={iconClassName} />; |
| 135 | 136 | } |
| 136 | 137 | |
| 137 | | function buildGitActionProgressStages(input: { |
| 138 | | action: GitStackedAction; |
| 139 | | hasCustomCommitMessage: boolean; |
| 140 | | hasWorkingTreeChanges: boolean; |
| 141 | | }): string[] { |
| 142 | | const shouldIncludeCommitStages = input.action === "commit" || input.hasWorkingTreeChanges; |
| 143 | | const commitStages = !shouldIncludeCommitStages |
| 144 | | ? [] |
| 145 | | : input.hasCustomCommitMessage |
| 146 | | ? ["Committing..."] |
| 147 | | : ["Generating commit message...", "Committing..."]; |
| 148 | | if (input.action === "commit") { |
| 149 | | return commitStages; |
| 150 | | } |
| 151 | | if (input.action === "commit_push") { |
| 152 | | return [...commitStages, "Pushing..."]; |
| 153 | | } |
| 154 | | return [...commitStages, "Pushing...", "Creating PR..."]; |
| 155 | | } |
| 156 | | |
| 157 | 138 | export default function GitActionsControl({ api, gitCwd }: GitActionsControlProps) { |
| 158 | 139 | const queryClient = useQueryClient(); |
| 159 | 140 | const [activeDialogAction, setActiveDialogAction] = useState<GitDialogAction | null>(null); |
| ... | ... | @@ -230,7 +211,15 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 230 | 211 | }, [api, gitStatus?.openPr?.url]); |
| 231 | 212 | |
| 232 | 213 | const runGitActionWithToast = useCallback( |
| 233 | | async ({ action, commitMessage }: { action: GitStackedAction; commitMessage?: string }) => { |
| 214 | async ({ |
| 215 | action, |
| 216 | commitMessage, |
| 217 | forcePushOnlyProgress = false, |
| 218 | }: { |
| 219 | action: GitStackedAction; |
| 220 | commitMessage?: string; |
| 221 | forcePushOnlyProgress?: boolean; |
| 222 | }) => { |
| 234 | 223 | const confirmed = await maybeConfirmPushToDefaultBranch(action); |
| 235 | 224 | if (!confirmed) return; |
| 236 | 225 | |
| ... | ... | @@ -238,6 +227,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 238 | 227 | action, |
| 239 | 228 | hasCustomCommitMessage: !!commitMessage?.trim(), |
| 240 | 229 | hasWorkingTreeChanges: !!gitStatus?.hasWorkingTreeChanges, |
| 230 | forcePushOnly: forcePushOnlyProgress, |
| 241 | 231 | }); |
| 242 | 232 | const progressToastId = toastManager.add({ |
| 243 | 233 | type: "loading", |
| ... | ... | @@ -290,7 +280,10 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 290 | 280 | children: "Push", |
| 291 | 281 | onClick: () => { |
| 292 | 282 | closeResultToast(); |
| 293 | | void runGitActionWithToast({ action: "commit_push" }); |
| 283 | void runGitActionWithToast({ |
| 284 | action: "commit_push", |
| 285 | forcePushOnlyProgress: true, |
| 286 | }); |
| 294 | 287 | }, |
| 295 | 288 | }, |
| 296 | 289 | } |
| ... | ... | @@ -381,7 +374,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 381 | 374 | return; |
| 382 | 375 | } |
| 383 | 376 | if (item.dialogAction === "push") { |
| 384 | | void runGitActionWithToast({ action: "commit_push" }); |
| 377 | void runGitActionWithToast({ action: "commit_push", forcePushOnlyProgress: true }); |
| 385 | 378 | return; |
| 386 | 379 | } |
| 387 | 380 | if (item.dialogAction) { |
| ... | ... | @@ -400,10 +393,12 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp |
| 400 | 393 | ? "commit_push" |
| 401 | 394 | : "commit_push_pr"; |
| 402 | 395 | const commitMessage = activeDialogAction === "commit" ? dialogCommitMessage.trim() : ""; |
| 396 | const forcePushOnlyProgress = activeDialogAction === "push"; |
| 403 | 397 | setActiveDialogAction(null); |
| 404 | 398 | void runGitActionWithToast({ |
| 405 | 399 | action, |
| 406 | 400 | ...(commitMessage ? { commitMessage } : {}), |
| 401 | ...(forcePushOnlyProgress ? { forcePushOnlyProgress } : {}), |
| 407 | 402 | }); |
| 408 | 403 | }, [activeDialogAction, dialogCommitMessage, runGitActionWithToast]); |
| 409 | 404 | |