Skip to content

Commit f265a14

Browse files
committed
Handle fork-origin PR status matching
1 parent 89d935a commit f265a14

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

apps/server/src/git/Layers/GitManager.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,35 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
21182118
}),
21192119
);
21202120

2121+
it.effect("accepts fork PR metadata when origin is the fork checkout remote", () =>
2122+
Effect.sync(() => {
2123+
const headContext = {
2124+
headBranch: "t3code/git-audit-stability",
2125+
headRepositoryNameWithOwner: "justsomelegs/t3code",
2126+
headRepositoryOwnerLogin: "justsomelegs",
2127+
isCrossRepository: false,
2128+
};
2129+
2130+
expect(
2131+
matchesBranchHeadContext(
2132+
{
2133+
number: 2284,
2134+
title: "Improve branch mismatch warnings",
2135+
url: "https://github.com/pingdotgg/t3code/pull/2284",
2136+
baseRefName: "main",
2137+
headRefName: "t3code/git-audit-stability",
2138+
state: "open",
2139+
updatedAt: null,
2140+
isCrossRepository: true,
2141+
headRepositoryNameWithOwner: "justsomelegs/t3code",
2142+
headRepositoryOwnerLogin: "justsomelegs",
2143+
},
2144+
headContext,
2145+
),
2146+
).toBe(true);
2147+
}),
2148+
);
2149+
21212150
it.effect("creates PR when one does not already exist", () =>
21222151
Effect.gen(function* () {
21232152
const repoDir = yield* makeTempDir("t3code-git-manager-");

apps/server/src/git/Layers/GitManager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,12 @@ export function matchesBranchHeadContext(
283283
}
284284

285285
if (pr.isCrossRepository === true) {
286-
return false;
286+
if (
287+
(!expectedHead.repositoryNameWithOwner && !expectedHead.ownerLogin) ||
288+
(!pullRequestHead.repositoryNameWithOwner && !pullRequestHead.ownerLogin)
289+
) {
290+
return false;
291+
}
287292
}
288293

289294
return true;

0 commit comments

Comments
 (0)