| ... | @@ -180,10 +180,19 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions | ... | @@ -180,10 +180,19 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 180 | const current = branchList?.branches.find((branch) => branch.name === branchName); | 180 | const current = branchList?.branches.find((branch) => branch.name === branchName); |
| 181 | return current?.isDefault ?? (branchName === "main" || branchName === "master"); | 181 | return current?.isDefault ?? (branchName === "main" || branchName === "master"); |
| 182 | }, [branchList?.branches, gitStatusForActions?.branch]); | 182 | }, [branchList?.branches, gitStatusForActions?.branch]); |
| | 183 | const isDefaultBranchName = useCallback( |
| | 184 | (branchName: string | null | undefined) => { |
| | 185 | if (!branchName) return false; |
| | 186 | const defaultBranchName = branchList?.branches.find((branch) => branch.isDefault)?.name; |
| | 187 | if (defaultBranchName) return branchName === defaultBranchName; |
| | 188 | return branchName === "main" || branchName === "master"; |
| | 189 | }, |
| | 190 | [branchList?.branches], |
| | 191 | ); |
| 183 | | 192 | |
| 184 | const gitActionMenuItems = useMemo( | 193 | const gitActionMenuItems = useMemo( |
| 185 | () => buildMenuItems(gitStatusForActions, isGitActionRunning), | 194 | () => buildMenuItems(gitStatusForActions, isGitActionRunning, isDefaultBranch), |
| 186 | [gitStatusForActions, isGitActionRunning], | 195 | [gitStatusForActions, isGitActionRunning, isDefaultBranch], |
| 187 | ); | 196 | ); |
| 188 | const quickAction = useMemo( | 197 | const quickAction = useMemo( |
| 189 | () => resolveQuickAction(gitStatusForActions, isGitActionRunning, isDefaultBranch), | 198 | () => resolveQuickAction(gitStatusForActions, isGitActionRunning, isDefaultBranch), |
| ... | @@ -237,6 +246,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions | ... | @@ -237,6 +246,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 237 | onConfirmed, | 246 | onConfirmed, |
| 238 | skipDefaultBranchPrompt = false, | 247 | skipDefaultBranchPrompt = false, |
| 239 | featureBranch = false, | 248 | featureBranch = false, |
| | 249 | isDefaultBranchOverride, |
| 240 | }: { | 250 | }: { |
| 241 | action: GitStackedAction; | 251 | action: GitStackedAction; |
| 242 | commitMessage?: string; | 252 | commitMessage?: string; |
| ... | @@ -244,10 +254,12 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions | ... | @@ -244,10 +254,12 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 244 | onConfirmed?: () => void; | 254 | onConfirmed?: () => void; |
| 245 | skipDefaultBranchPrompt?: boolean; | 255 | skipDefaultBranchPrompt?: boolean; |
| 246 | featureBranch?: boolean; | 256 | featureBranch?: boolean; |
| | 257 | isDefaultBranchOverride?: boolean; |
| 247 | }) => { | 258 | }) => { |
| 248 | const actionStatus = gitStatusForActions; | 259 | const actionStatus = gitStatusForActions; |
| 249 | const actionIsDefaultBranch = featureBranch ? false : isDefaultBranch; | | |
| 250 | const actionBranch = actionStatus?.branch ?? null; | 260 | const actionBranch = actionStatus?.branch ?? null; |
| | 261 | const actionIsDefaultBranch = |
| | 262 | isDefaultBranchOverride ?? (featureBranch ? false : isDefaultBranchName(actionBranch)); |
| 251 | const includesCommit = | 263 | const includesCommit = |
| 252 | !forcePushOnlyProgress && (action === "commit" || !!actionStatus?.hasWorkingTreeChanges); | 264 | !forcePushOnlyProgress && (action === "commit" || !!actionStatus?.hasWorkingTreeChanges); |
| 253 | if ( | 265 | if ( |
| ... | @@ -348,6 +360,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions | ... | @@ -348,6 +360,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 348 | forcePushOnlyProgress: true, | 360 | forcePushOnlyProgress: true, |
| 349 | onConfirmed: closeResultToast, | 361 | onConfirmed: closeResultToast, |
| 350 | ...(featureBranch ? { skipDefaultBranchPrompt: true } : {}), | 362 | ...(featureBranch ? { skipDefaultBranchPrompt: true } : {}), |
| | 363 | ...(featureBranch ? { isDefaultBranchOverride: false } : {}), |
| 351 | }); | 364 | }); |
| 352 | }, | 365 | }, |
| 353 | }, | 366 | }, |
| ... | @@ -374,6 +387,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions | ... | @@ -374,6 +387,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 374 | action: "commit_push_pr", | 387 | action: "commit_push_pr", |
| 375 | forcePushOnlyProgress: true, | 388 | forcePushOnlyProgress: true, |
| 376 | ...(featureBranch ? { skipDefaultBranchPrompt: true } : {}), | 389 | ...(featureBranch ? { skipDefaultBranchPrompt: true } : {}), |
| | 390 | ...(featureBranch ? { isDefaultBranchOverride: false } : {}), |
| 377 | }); | 391 | }); |
| 378 | }, | 392 | }, |
| 379 | }, | 393 | }, |
| ... | @@ -392,7 +406,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions | ... | @@ -392,7 +406,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 392 | }, | 406 | }, |
| 393 | | 407 | |
| 394 | [ | 408 | [ |
| 395 | isDefaultBranch, | 409 | isDefaultBranchName, |
| 396 | runImmediateGitActionMutation, | 410 | runImmediateGitActionMutation, |
| 397 | setPendingDefaultBranchAction, | 411 | setPendingDefaultBranchAction, |
| 398 | threadToastData, | 412 | threadToastData, |
| ... | @@ -410,6 +424,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions | ... | @@ -410,6 +424,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions |
| 410 | forcePushOnlyProgress, | 424 | forcePushOnlyProgress, |
| 411 | ...(onConfirmed ? { onConfirmed } : {}), | 425 | ...(onConfirmed ? { onConfirmed } : {}), |
| 412 | skipDefaultBranchPrompt: true, | 426 | skipDefaultBranchPrompt: true, |
| | 427 | isDefaultBranchOverride: true, |
| 413 | }); | 428 | }); |
| 414 | }, [pendingDefaultBranchAction, runGitActionWithToast]); | 429 | }, [pendingDefaultBranchAction, runGitActionWithToast]); |
| 415 | | 430 | |