mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-04 07:33:18 +00:00
Preserve local branch names when checking merge targets
This commit is contained in:
@@ -226,6 +226,23 @@ describe("git-actions-policy", () => {
|
||||
expect(isCurrentBranchLocalMergeTarget("release", "refs/remotes/upstream/release")).toBe(false);
|
||||
});
|
||||
|
||||
it("offers local merge when the selected local base starts with origin slash", () => {
|
||||
const actions = buildGitActions(
|
||||
createInput({
|
||||
isPaseoOwnedWorktree: true,
|
||||
isOnBaseBranch: isCurrentBranchBase("release", "refs/heads/origin/release"),
|
||||
isOnLocalMergeTarget: isCurrentBranchLocalMergeTarget(
|
||||
"release",
|
||||
"refs/heads/origin/release",
|
||||
),
|
||||
baseRefLabel: "origin/release",
|
||||
aheadCount: 1,
|
||||
shipDefault: "merge",
|
||||
}),
|
||||
);
|
||||
expect(actions.primary?.id).toBe("merge-branch");
|
||||
});
|
||||
|
||||
it("does not offer merging into the current local branch when the remote base shares its name", () => {
|
||||
const actions = buildGitActions(
|
||||
createInput({
|
||||
|
||||
@@ -66,10 +66,7 @@ export function isCurrentBranchLocalMergeTarget(
|
||||
baseRef: string | null | undefined,
|
||||
): boolean {
|
||||
if (!currentBranch || !baseRef) return false;
|
||||
const localTarget = baseRef
|
||||
.replace(/^refs\/heads\//, "")
|
||||
.replace(/^refs\/remotes\/origin\//, "")
|
||||
.replace(/^origin\//, "");
|
||||
const localTarget = baseRef.replace(/^(?:refs\/heads\/|refs\/remotes\/origin\/|origin\/)/, "");
|
||||
return currentBranch === localTarget;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user