Fix duplicated branch logic and feature-branch dialog on push-only
Deduplicate feature/ prefix logic in resolveAutoFeatureBranchName by delegating to sanitizeFeatureBranchName. Skip the default-branch confirmation dialog when there are no uncommitted changes (push-only), since runFeatureBranchStep requires dirty worktree. Add merge-base assertions to feature branch tests. Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
1 parent
906550f9af
commit
61289a152d
3 files changed
+19
-7
No files matched your search
@@ -563,6 +563,14 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
|
||||
Effect.map((result) => result.stdout.trim()),
|
||||
),
|
||||
).toBe("feature/implement-stacked-git-actions");
|
||||
|
||||
const mainSha = yield* runGit(repoDir, ["rev-parse", "main"]).pipe(
|
||||
Effect.map((r) => r.stdout.trim()),
|
||||
);
|
||||
const mergeBase = yield* runGit(repoDir, ["merge-base", "main", "HEAD"]).pipe(
|
||||
Effect.map((r) => r.stdout.trim()),
|
||||
);
|
||||
expect(mergeBase).toBe(mainSha);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -598,6 +606,14 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
|
||||
expect(result.commit.status).toBe("created");
|
||||
expect(result.commit.subject).toBe("feat: custom summary line");
|
||||
expect(generatedCount).toBe(0);
|
||||
|
||||
const mainSha = yield* runGit(repoDir, ["rev-parse", "main"]).pipe(
|
||||
Effect.map((r) => r.stdout.trim()),
|
||||
);
|
||||
const mergeBase = yield* runGit(repoDir, ["merge-base", "main", result.branch.name!]).pipe(
|
||||
Effect.map((r) => r.stdout.trim()),
|
||||
);
|
||||
expect(mergeBase).toBe(mainSha);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -254,7 +254,8 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
|
||||
!skipDefaultBranchPrompt &&
|
||||
!featureBranch &&
|
||||
requiresDefaultBranchConfirmation(action, actionIsDefaultBranch) &&
|
||||
actionBranch
|
||||
actionBranch &&
|
||||
!!actionStatus?.hasWorkingTreeChanges
|
||||
) {
|
||||
if (action !== "commit_push" && action !== "commit_push_pr") {
|
||||
return;
|
||||
|
||||
@@ -43,14 +43,9 @@ export function resolveAutoFeatureBranchName(
|
||||
preferredBranch?: string,
|
||||
): string {
|
||||
const preferred = preferredBranch?.trim();
|
||||
const normalized = sanitizeBranchFragment(
|
||||
const resolvedBase = sanitizeFeatureBranchName(
|
||||
preferred && preferred.length > 0 ? preferred : AUTO_FEATURE_BRANCH_FALLBACK,
|
||||
);
|
||||
const resolvedBase = normalized.includes("/")
|
||||
? normalized.startsWith("feature/")
|
||||
? normalized
|
||||
: `feature/${normalized}`
|
||||
: `feature/${normalized}`;
|
||||
const existingNames = new Set(existingBranchNames);
|
||||
|
||||
if (!existingNames.has(resolvedBase)) {
|
||||
|
||||
Reference in new issue
Block a user