Fix cross-repo PR identity matching
This commit is contained in:
1 parent
d7cc9174ae
commit
eb9b509af8
2 files changed
+77
-1
No files matched your search
@@ -2035,6 +2035,72 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
|
||||
12_000,
|
||||
);
|
||||
|
||||
it.effect(
|
||||
"does not reuse a cross-repo PR when GitHub omits head identity metadata",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const repoDir = yield* makeTempDir("t3code-git-manager-");
|
||||
yield* initRepo(repoDir);
|
||||
yield* runGit(repoDir, ["checkout", "-b", "statemachine"]);
|
||||
const forkDir = yield* createBareRemote();
|
||||
yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);
|
||||
yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
|
||||
yield* runGit(repoDir, [
|
||||
"config",
|
||||
"remote.fork-seed.url",
|
||||
"[email protected]:octocat/codething-mvp.git",
|
||||
]);
|
||||
|
||||
const { manager, ghCalls } = yield* makeManager({
|
||||
ghScenario: {
|
||||
prListSequenceByHeadSelector: {
|
||||
"octocat:statemachine": [
|
||||
JSON.stringify([
|
||||
{
|
||||
number: 41,
|
||||
title: "Ambiguous fork PR",
|
||||
url: "https://github.com/pingdotgg/codething-mvp/pull/41",
|
||||
baseRefName: "main",
|
||||
headRefName: "statemachine",
|
||||
state: "OPEN",
|
||||
},
|
||||
]),
|
||||
JSON.stringify([
|
||||
{
|
||||
number: 142,
|
||||
title: "Add stacked git actions",
|
||||
url: "https://github.com/pingdotgg/codething-mvp/pull/142",
|
||||
baseRefName: "main",
|
||||
headRefName: "statemachine",
|
||||
state: "OPEN",
|
||||
isCrossRepository: true,
|
||||
headRepository: {
|
||||
nameWithOwner: "octocat/codething-mvp",
|
||||
},
|
||||
headRepositoryOwner: {
|
||||
login: "octocat",
|
||||
},
|
||||
},
|
||||
]),
|
||||
],
|
||||
"fork-seed:statemachine": [JSON.stringify([])],
|
||||
statemachine: [JSON.stringify([])],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const result = yield* runStackedAction(manager, {
|
||||
cwd: repoDir,
|
||||
action: "commit_push_pr",
|
||||
});
|
||||
|
||||
expect(result.pr.status).toBe("created");
|
||||
expect(result.pr.number).toBe(142);
|
||||
expect(ghCalls.some((call) => call.startsWith("pr create "))).toBe(true);
|
||||
}),
|
||||
12_000,
|
||||
);
|
||||
|
||||
it.effect("creates PR when one does not already exist", () =>
|
||||
Effect.gen(function* () {
|
||||
const repoDir = yield* makeTempDir("t3code-git-manager-");
|
||||
|
||||
@@ -266,7 +266,17 @@ function matchesBranchHeadContext(
|
||||
}
|
||||
|
||||
if (headContext.isCrossRepository) {
|
||||
return pr.isCrossRepository !== false;
|
||||
if (pr.isCrossRepository === false) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
(expectedHead.repositoryNameWithOwner || expectedHead.ownerLogin) &&
|
||||
!pullRequestHead.repositoryNameWithOwner &&
|
||||
!pullRequestHead.ownerLogin
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pr.isCrossRepository === true) {
|
||||
|
||||
Reference in new issue
Block a user