GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): wake GitLab MR watches when a rebase is required (#30312) · pingdotgg/t3code@f5ca0f9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src
    • orchestration-v2
      • Orchestrator.ts
      • PullRequestSyncReactor.test.ts
      • PullRequestSyncReactor.ts
      • PullRequestWatchReactor.ts
      • pullRequestWatch.test.ts
      • pullRequestWatch.ts
    • pullRequest
      • PullRequestService.test.ts
      • PullRequestService.ts
  • packages
    • contracts/src
      • pullRequest.ts
      • threadPullRequest.ts
    • source-control-core/src/server
      • PullRequestProvider.ts
    • source-control-gitlab/src/server
      • gitLabMergeRequestJson.test.ts
      • gitLabMergeRequestJson.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Orchestrator.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5065,6 +5065,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
50655065
passed: existing.endedWatch.passed,
50665066
passedChecks: existing.endedWatch.passedChecks,
50675067
conflicting: existing.endedWatch.conflicting,
5068+
rebaseRequired: existing.endedWatch.rebaseRequired,
50685069
}),
50695070
awaitingBaseline: existing.endedWatch
50705071
? existing.endedWatch.awaitingBaseline
Collapse file

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,39 @@ describe("PullRequestSyncReactor", () => {
613613
}).pipe(Effect.provide(fixture.layer));
614614
}),
615615
);
616+
it.effect("syncs a rebase blocker even when the PR timestamp is unchanged", () =>
617+
Effect.scoped(
618+
Effect.gen(function* () {
619+
yield* TestClock.setTime(Date.parse(NOW));
620+
const required = yield* Ref.make(false);
621+
const fixture = yield* makeHarness({
622+
snapshot: makeSnapshot([makeThread("rebase", { pullRequests: [makeLink(7)] })]),
623+
summary: (input) =>
624+
Ref.get(required).pipe(
625+
Effect.map((rebaseRequired) => makeSummary(input, { rebaseRequired })),
626+
),
627+
});
628+
yield* Effect.gen(function* () {
629+
const reactor = yield* startAndSweep(fixture);
630+
yield* applyRecordedSyncs(fixture);
631+
yield* Ref.set(required, true);
632+
yield* reactor.requestSync({
633+
host: "github.com",
634+
repository: "owner/repository",
635+
number: 7,
636+
});
637+
yield* Queue.take(fixture.snapshotReads);
638+
yield* reactor.drain;
639+
const commands = yield* Ref.get(fixture.syncCommands);
640+
assert.equal(commands.length, 2);
641+
assert.equal(commands[0]?.snapshot?.rebaseRequired, false);
642+
assert.equal(commands[1]?.snapshot?.rebaseRequired, true);
643+
assert.equal(commands[0]?.snapshot?.updatedAt, commands[1]?.snapshot?.updatedAt);
644+
}).pipe(Effect.provide(fixture.layer));
645+
}),
646+
),
647+
);
648+
616649
it.effect("snapshots an unsynced link once and writes it to the thread", () =>
617650
Effect.gen(function* () {
618651
yield* TestClock.setTime(Date.parse(NOW));
Collapse file

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/PullRequestSyncReactor.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ function snapshotFieldsOf(summary: PullRequestSummary): SnapshotFields {
234234
...(summary.reviewDecision === undefined ? {} : { reviewDecision: summary.reviewDecision }),
235235
...(summary.checksState === undefined ? {} : { checksState: summary.checksState }),
236236
...(summary.mergeability === undefined ? {} : { mergeability: summary.mergeability }),
237+
...(summary.rebaseRequired === undefined ? {} : { rebaseRequired: summary.rebaseRequired }),
237238
};
238239
}
239240

@@ -282,7 +283,8 @@ function snapshotFieldsEqual(left: SnapshotFields, right: SnapshotFields): boole
282283
left.changedFiles === right.changedFiles &&
283284
(left.reviewDecision ?? null) === (right.reviewDecision ?? null) &&
284285
(left.checksState ?? null) === (right.checksState ?? null) &&
285-
left.mergeability === right.mergeability
286+
left.mergeability === right.mergeability &&
287+
left.rebaseRequired === right.rebaseRequired
286288
);
287289
}
288290

Collapse file

‎apps/server/src/orchestration-v2/PullRequestWatchReactor.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/PullRequestWatchReactor.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ const snapshotFingerprint = ({ link }: WatchTarget) => {
151151
snapshot.updatedAt,
152152
snapshot.checksState,
153153
snapshot.mergeability,
154+
snapshot.rebaseRequired,
154155
snapshot.reviewDecision,
155156
snapshot.isDraft,
156157
].join(" ");
@@ -212,6 +213,7 @@ function watchesEqual(left: ThreadPullRequestWatch, right: ThreadPullRequestWatc
212213
left.remarksThrough === right.remarksThrough &&
213214
left.remarkIds.join("\n") === right.remarkIds.join("\n") &&
214215
left.conflicting === right.conflicting &&
216+
left.rebaseRequired === right.rebaseRequired &&
215217
left.mergeQueueRemovalId === right.mergeQueueRemovalId &&
216218
left.wakes === right.wakes &&
217219
left.awaitingBaseline === right.awaitingBaseline &&
Collapse file

‎apps/server/src/orchestration-v2/pullRequestWatch.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/pullRequestWatch.test.ts
+47-1Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,45 @@ const remark = (
8181
const noRemarks: ReadonlyArray<PullRequestComment> = [];
8282

8383
describe("evaluatePullRequestWatch", () => {
84+
it.each(["pending", "success"] as const)(
85+
"reports a required rebase once with %s CI",
86+
(status) => {
87+
const blocked = detail({
88+
mergeability: "unknown",
89+
rebaseRequired: true,
90+
checks: [check("test", status)],
91+
});
92+
const first = evaluatePullRequestWatch(watch(), blocked, noRemarks);
93+
assert.include(
94+
first.changes.map((change) => change.kind),
95+
"needs-rebase",
96+
);
97+
assert.deepEqual(evaluatePullRequestWatch(first.next, blocked, noRemarks).changes, []);
98+
const unknown = evaluatePullRequestWatch(
99+
first.next,
100+
{ ...blocked, rebaseRequired: undefined },
101+
noRemarks,
102+
);
103+
assert.deepEqual(evaluatePullRequestWatch(unknown.next, blocked, noRemarks).changes, []);
104+
const clean = evaluatePullRequestWatch(
105+
first.next,
106+
{ ...blocked, rebaseRequired: false },
107+
noRemarks,
108+
);
109+
assert.deepEqual(evaluatePullRequestWatch(clean.next, blocked, noRemarks).changes, [
110+
{ kind: "needs-rebase" },
111+
]);
112+
assert.include(
113+
evaluatePullRequestWatch(
114+
first.next,
115+
{ ...blocked, headSha: "bbbbbbbbbb" },
116+
noRemarks,
117+
).changes.map((change) => change.kind),
118+
"needs-rebase",
119+
);
120+
},
121+
);
122+
84123
it.each([false, true])("baselines already-passed checks (required: %s)", (required) => {
85124
const green = detail({ checks: [{ ...check("test", "success"), required }] });
86125
const baseline = evaluatePullRequestWatch(watch({ awaitingBaseline: "all" }), green, noRemarks);
@@ -115,6 +154,7 @@ describe("evaluatePullRequestWatch", () => {
115154
const broken = detail({
116155
checks: [check("lint", "failure"), check("test", "pending")],
117156
mergeability: "conflicting",
157+
rebaseRequired: true,
118158
});
119159
const baseline = evaluatePullRequestWatch(
120160
watch({ awaitingBaseline: "all" }),
@@ -125,6 +165,7 @@ describe("evaluatePullRequestWatch", () => {
125165
assert.deepEqual(baseline.next.failedChecks, ["lint"]);
126166
assert.isFalse(baseline.next.passed);
127167
assert.isTrue(baseline.next.conflicting);
168+
assert.isTrue(baseline.next.rebaseRequired);
128169
assert.deepEqual(evaluatePullRequestWatch(baseline.next, broken, noRemarks).changes, []);
129170

130171
const failed = evaluatePullRequestWatch(
@@ -135,11 +176,16 @@ describe("evaluatePullRequestWatch", () => {
135176
assert.deepEqual(failed.changes, [
136177
{ kind: "checks-failed", failed: [check("test", "failure")] },
137178
]);
138-
const clean = evaluatePullRequestWatch(failed.next, detail(), noRemarks);
179+
const clean = evaluatePullRequestWatch(
180+
failed.next,
181+
detail({ rebaseRequired: false }),
182+
noRemarks,
183+
);
139184
assert.deepEqual(clean.changes, []);
140185
assert.deepEqual(evaluatePullRequestWatch(clean.next, broken, noRemarks).changes, [
141186
{ kind: "checks-failed", failed: [check("lint", "failure")] },
142187
{ kind: "conflicting" },
188+
{ kind: "needs-rebase" },
143189
]);
144190
});
145191

Collapse file

‎apps/server/src/orchestration-v2/pullRequestWatch.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/pullRequestWatch.ts
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type PullRequestWatchChange =
2121
| { readonly kind: "remarks"; readonly remarks: ReadonlyArray<PullRequestComment> }
2222
| { readonly kind: "no-checks"; readonly minutes: number }
2323
| { readonly kind: "conflicting" }
24+
| { readonly kind: "needs-rebase" }
2425
| { readonly kind: "merge-queue-removed"; readonly reason: string | null };
2526

2627
export interface PullRequestWatchReport {
@@ -46,6 +47,7 @@ export function evaluatePullRequestWatch(
4647
| "mergeability"
4748
| "viewer"
4849
| "author"
50+
| "rebaseRequired"
4951
| "mergeQueueRemoval"
5052
>,
5153
remarks: ReadonlyArray<PullRequestComment> | null,
@@ -196,11 +198,16 @@ export function evaluatePullRequestWatch(
196198
...atLatest.map((remark) => remark.id),
197199
];
198200

199-
// Like a failed check, a conflict a push did not resolve is news for the new head.
201+
// Like a failed check, a conflict or rebase a push did not resolve is news for the new head.
200202
const toldConflict = !headMoved && watch.conflicting;
201203
if (watch.awaitingBaseline !== "all" && detail.mergeability === "conflicting" && !toldConflict) {
202204
changes.push({ kind: "conflicting" });
203205
}
206+
const toldRebase = !headMoved && watch.rebaseRequired === true;
207+
if (watch.awaitingBaseline !== "all" && detail.rebaseRequired === true && !toldRebase) {
208+
changes.push({ kind: "needs-rebase" });
209+
}
210+
const rebaseRequired = detail.rebaseRequired ?? watch.rebaseRequired;
204211
// "unknown" is a host still computing after a push; only a clean answer clears a conflict.
205212
const conflicting =
206213
detail.mergeability === "unknown" ? toldConflict : detail.mergeability === "conflicting";
@@ -239,6 +246,7 @@ export function evaluatePullRequestWatch(
239246
remarksThrough,
240247
remarkIds,
241248
conflicting,
249+
rebaseRequired,
242250
mergeQueueRemovalId,
243251
wakes,
244252
// Only a read that cannot be trusted to show the checks leaves the baseline to the next one.
@@ -308,6 +316,8 @@ function changeLines(
308316
return [
309317
`- No checks have reported${context.commit} after ${change.minutes} minutes. None may be configured to run on this change.`,
310318
];
319+
case "needs-rebase":
320+
return [`- The branch requires a rebase onto ${context.baseBranch}.`];
311321
case "conflicting":
312322
return [`- The branch now conflicts with ${context.baseBranch}.`];
313323
case "merge-queue-removed":
@@ -324,6 +334,7 @@ const SUMMARY: Record<PullRequestWatchChange["kind"], string> = {
324334
remarks: "new comments",
325335
"no-checks": "no checks reported",
326336
conflicting: "merge conflict",
337+
"needs-rebase": "rebase required",
327338
"merge-queue-removed": "removed from merge queue",
328339
};
329340

@@ -388,6 +399,7 @@ export function pullRequestWatchMessage(input: {
388399
(change) =>
389400
change.kind === "checks-failed" ||
390401
change.kind === "conflicting" ||
402+
change.kind === "needs-rebase" ||
391403
change.kind === "merge-queue-removed",
392404
);
393405
const summary = changes.map((change) => SUMMARY[change.kind]);
Collapse file

‎apps/server/src/pullRequest/PullRequestService.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/pullRequest/PullRequestService.test.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,6 +3458,7 @@ it.effect(
34583458
Effect.succeed({
34593459
...changeRequest(1, "2026-07-02T00:00:00Z"),
34603460
isDraft: true,
3461+
rebaseRequired: false,
34613462
reviewDecision: "approved",
34623463
checksState: "passing",
34633464
}),
@@ -3467,13 +3468,16 @@ it.effect(
34673468
deletions: 3,
34683469
changedFiles: 5,
34693470
mergeability: "conflicting",
3471+
rebaseRequired: true,
34703472
}),
34713473
}),
34723474
],
34733475
});
34743476
yield* service.summary(reference);
34753477
const detail = yield* service.detail(reference);
34763478
const summary = yield* service.summary(reference);
3479+
assert.strictEqual(detail.rebaseRequired, true);
3480+
assert.strictEqual(summary.rebaseRequired, true);
34773481
assert.strictEqual(summary.isDraft, false);
34783482
assert.deepStrictEqual(summary.author, detail.author);
34793483
assert.strictEqual(summary.additions, 14);
Collapse file

‎apps/server/src/pullRequest/PullRequestService.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/pullRequest/PullRequestService.ts
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,9 @@ export const make = Effect.gen(function* () {
13091309
state: input.item.state,
13101310
isDraft: input.item.isDraft,
13111311
mergeability: input.item.mergeability,
1312+
...(input.item.rebaseRequired === undefined
1313+
? {}
1314+
: { rebaseRequired: input.item.rebaseRequired }),
13121315
additions: input.item.additions,
13131316
deletions: input.item.deletions,
13141317
createdAt: input.item.createdAt,
@@ -1792,6 +1795,9 @@ export const make = Effect.gen(function* () {
17921795
...(changeRequest.mergeability === undefined
17931796
? {}
17941797
: { mergeability: changeRequest.mergeability }),
1798+
...(changeRequest.rebaseRequired === undefined
1799+
? {}
1800+
: { rebaseRequired: changeRequest.rebaseRequired }),
17951801
...(changeRequest.stack === undefined ? {} : { stack: changeRequest.stack }),
17961802
...(changeRequest.headSha?.trim() ? { headSha: changeRequest.headSha.trim() } : {}),
17971803
...(changeRequest.autoMergeEnabled === undefined
@@ -1891,6 +1897,9 @@ export const make = Effect.gen(function* () {
18911897
state: changeRequest.state,
18921898
isDraft: changeRequest.isDraft,
18931899
mergeability: changeRequest.mergeability,
1900+
...(changeRequest.rebaseRequired === undefined
1901+
? {}
1902+
: { rebaseRequired: changeRequest.rebaseRequired }),
18941903
additions: changeRequest.additions,
18951904
deletions: changeRequest.deletions,
18961905
changedFiles: changeRequest.changedFiles,
@@ -3330,6 +3339,7 @@ export const make = Effect.gen(function* () {
33303339
deletions: detail.deletions,
33313340
changedFiles: detail.changedFiles,
33323341
mergeability: detail.mergeability,
3342+
...(detail.rebaseRequired === undefined ? {} : { rebaseRequired: detail.rebaseRequired }),
33333343
headBranch: detail.headBranch,
33343344
baseBranch: detail.baseBranch,
33353345
closedAt: detail.closedAt,
Collapse file

‎packages/contracts/src/pullRequest.ts‎

Copy file name to clipboardExpand all lines: packages/contracts/src/pullRequest.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ export const PullRequestListEntry = Schema.Struct({
370370
state: PullRequestState,
371371
isDraft: Schema.Boolean,
372372
mergeability: PullRequestMergeability,
373+
rebaseRequired: Schema.optional(Schema.Boolean),
373374
/** Zero until fetched through `PullRequestListStatsInput`; GitHub listings omit counts. */
374375
additions: NonNegativeInt,
375376
deletions: NonNegativeInt,
@@ -528,6 +529,7 @@ export const PullRequestSummary = Schema.Struct({
528529
reviewDecision: Schema.optional(Schema.NullOr(PullRequestReviewDecision)),
529530
checksState: Schema.optional(Schema.NullOr(PullRequestChecksState)),
530531
mergeability: Schema.optional(PullRequestMergeability),
532+
rebaseRequired: Schema.optional(Schema.Boolean),
531533
/** Null when the host says the pull request is in no stack; absent when the read did not ask. */
532534
stack: Schema.optional(Schema.NullOr(PullRequestStackMembership)),
533535
headSha: Schema.optional(TrimmedNonEmptyString),
@@ -651,6 +653,7 @@ export const PullRequestDetail = Schema.Struct({
651653
state: PullRequestState,
652654
isDraft: Schema.Boolean,
653655
mergeability: PullRequestMergeability,
656+
rebaseRequired: Schema.optional(Schema.Boolean),
654657
additions: NonNegativeInt,
655658
deletions: NonNegativeInt,
656659
changedFiles: NonNegativeInt,
Collapse file

‎packages/contracts/src/threadPullRequest.ts‎

Copy file name to clipboardExpand all lines: packages/contracts/src/threadPullRequest.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const ThreadPullRequestSnapshot = Schema.Struct({
5151
reviewDecision: Schema.optional(Schema.NullOr(PullRequestReviewDecision)),
5252
checksState: Schema.optional(Schema.NullOr(PullRequestChecksState)),
5353
mergeability: Schema.optional(PullRequestMergeability),
54+
rebaseRequired: Schema.optional(Schema.Boolean),
5455
});
5556
export type ThreadPullRequestSnapshot = typeof ThreadPullRequestSnapshot.Type;
5657

@@ -97,6 +98,7 @@ export const ThreadPullRequestWatch = Schema.Struct({
9798
/** Reported remarks at remarksThrough, so late arrivals at that timestamp still count. */
9899
remarkIds: Schema.Array(TrimmedNonEmptyString),
99100
conflicting: Schema.Boolean,
101+
rebaseRequired: Schema.optional(Schema.Boolean),
100102
/** Last removal seen; null after an empty read, absent before the first read. */
101103
mergeQueueRemovalId: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
102104
/** Consecutive comment-only wakes; limited to prevent bot loops. */

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.