Fix default branch confirmation dialog for push and create_pr menu actions
The menu's push and create_pr actions bypassed the default branch confirmation dialog because requiresDefaultBranchConfirmation only checked for commit_push and commit_push_pr. Extend the check to also cover the split push and create_pr actions, and update the action guard and dialog copy resolver to handle them. Applied via @cursor push command
This commit is contained in:
1 parent
5dc3c21250
commit
81eabe2f7b
3 files changed
+21
-4
No files matched your search
@@ -802,9 +802,12 @@ describe("when: branch has no upstream configured", () => {
|
||||
describe("requiresDefaultBranchConfirmation", () => {
|
||||
it("requires confirmation for push actions on default branch", () => {
|
||||
assert.isFalse(requiresDefaultBranchConfirmation("commit", true));
|
||||
assert.isTrue(requiresDefaultBranchConfirmation("push", true));
|
||||
assert.isTrue(requiresDefaultBranchConfirmation("create_pr", true));
|
||||
assert.isTrue(requiresDefaultBranchConfirmation("commit_push", true));
|
||||
assert.isTrue(requiresDefaultBranchConfirmation("commit_push_pr", true));
|
||||
assert.isFalse(requiresDefaultBranchConfirmation("commit_push", false));
|
||||
assert.isFalse(requiresDefaultBranchConfirmation("push", false));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -31,7 +31,11 @@ export interface DefaultBranchActionDialogCopy {
|
||||
continueLabel: string;
|
||||
}
|
||||
|
||||
export type DefaultBranchConfirmableAction = "commit_push" | "commit_push_pr";
|
||||
export type DefaultBranchConfirmableAction =
|
||||
| "push"
|
||||
| "create_pr"
|
||||
| "commit_push"
|
||||
| "commit_push_pr";
|
||||
|
||||
export function buildGitActionProgressStages(input: {
|
||||
action: GitStackedAction;
|
||||
@@ -272,7 +276,12 @@ export function requiresDefaultBranchConfirmation(
|
||||
isDefaultBranch: boolean,
|
||||
): boolean {
|
||||
if (!isDefaultBranch) return false;
|
||||
return action === "commit_push" || action === "commit_push_pr";
|
||||
return (
|
||||
action === "push" ||
|
||||
action === "create_pr" ||
|
||||
action === "commit_push" ||
|
||||
action === "commit_push_pr"
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveDefaultBranchActionDialogCopy(input: {
|
||||
@@ -283,7 +292,7 @@ export function resolveDefaultBranchActionDialogCopy(input: {
|
||||
const branchLabel = input.branchName;
|
||||
const suffix = ` on "${branchLabel}". You can continue on this branch or create a feature branch and run the same action there.`;
|
||||
|
||||
if (input.action === "commit_push") {
|
||||
if (input.action === "push" || input.action === "commit_push") {
|
||||
if (input.includesCommit) {
|
||||
return {
|
||||
title: "Commit & push to default branch?",
|
||||
|
||||
@@ -425,7 +425,12 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
|
||||
requiresDefaultBranchConfirmation(action, actionIsDefaultBranch) &&
|
||||
actionBranch
|
||||
) {
|
||||
if (action !== "commit_push" && action !== "commit_push_pr") {
|
||||
if (
|
||||
action !== "push" &&
|
||||
action !== "create_pr" &&
|
||||
action !== "commit_push" &&
|
||||
action !== "commit_push_pr"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
setPendingDefaultBranchAction({
|
||||
|
||||
Reference in new issue
Block a user