Skip to content

Commit b587109

Browse files
fix(gitcafe): open pull requests whose merge state is none or pending
git.cafe reports merge conflicts as "none" and "pending" as well as the documented "unknown" and "conflicting". The driver accepted only the documented two, so a pull request without conflicts failed to open with "GitCafe returned an unreadable response". Any state is now read; "none" shows as mergeable and unknown states as unknown. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a44faac commit b587109

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ describe("GitCafePullRequestProvider", () => {
456456
"GET /repos/owner/repo/pulls/7/labels": { items: [labels[0]], next: null },
457457
"GET /repos/owner/repo/pulls/7/status": {
458458
merge: {
459-
conflicts: "unknown",
459+
conflicts: "none",
460460
fastForward: true,
461461
strategies: ["merge", "squash", "rebase"],
462462
blockers: [{ blockedStrategies: ["squash"] }, {}],
@@ -491,7 +491,12 @@ describe("GitCafePullRequestProvider", () => {
491491
return Effect.gen(function* () {
492492
const provider = yield* GitCafePullRequestProvider.make;
493493
const detail = yield* provider.getChangeRequest(target);
494-
assert.deepInclude(detail, { additions: 6, deletions: 3, changedFiles: 3 });
494+
assert.deepInclude(detail, {
495+
additions: 6,
496+
deletions: 3,
497+
changedFiles: 3,
498+
mergeability: "mergeable",
499+
});
495500
assert.strictEqual(
496501
server.sent.filter((request) => request.path.endsWith("/changes"))[1]?.query.get("after"),
497502
"cursor-1",

‎packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ const Versioned = Schema.Struct({ version: NonNegativeInt });
7878
const CommentDetail = Schema.Struct({ id: Id, version: NonNegativeInt });
7979
const Status = Schema.Struct({
8080
merge: Schema.Struct({
81-
conflicts: Schema.Literals(["unknown", "conflicting"]),
81+
// The API reference lists "unknown" and "conflicting", but git.cafe also sends "none" and
82+
// "pending", so any state is read and only the known ones are mapped.
83+
conflicts: Schema.String,
8284
fastForward: Schema.NullOr(Schema.Boolean),
8385
strategies: Schema.Array(Schema.String),
8486
permitted: Schema.optional(Schema.Boolean),
@@ -631,7 +633,9 @@ export const make = Effect.gen(function* () {
631633
mergeability:
632634
status.merge.conflicts === "conflicting"
633635
? ("conflicting" as const)
634-
: ("unknown" as const),
636+
: status.merge.conflicts === "none"
637+
? ("mergeable" as const)
638+
: ("unknown" as const),
635639
baseComparison:
636640
status.merge.fastForward === null
637641
? ("unknown" as const)

0 commit comments

Comments
 (0)