Gas waits for GitLab to compute mergeability instead of refusing. An unchecked (or checking/preparing/approvals_syncing) status now makes the Hub ask for a recheck as the merge account, every 30 seconds, and give up only after two minutes; lti-api !1384 was refused twice because nobody ever asked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,9 @@ function world(config: Partial<HubConfig> = {}) {
|
||||
changes: { mrs: [], commits: [] } as { mrs: Array<{ iid: number; title: string; author: string }>; commits: Array<{ sha: string; title: string }> },
|
||||
created: [] as Array<{ name: string; sha: string; message: string }>,
|
||||
closed: [] as number[],
|
||||
// Asks for a mergeability recheck; what GitLab answers on the next read (null: it stays as it is).
|
||||
rechecks: [] as number[],
|
||||
recheckTo: 'mergeable' as string | null,
|
||||
};
|
||||
const calls = { connect: [] as Array<string | null>, review: [] as Array<string | null>, ask: [] as string[] };
|
||||
let outcomes: Array<() => any> = [];
|
||||
@@ -64,6 +67,13 @@ function world(config: Partial<HubConfig> = {}) {
|
||||
updateNote: async (ref, id, body) => {
|
||||
gl.posted.push({ iid: ref.iid, id, body, edit: true });
|
||||
},
|
||||
recheckMergeStatus: async (ref) => {
|
||||
gl.rechecks.push(ref.iid);
|
||||
const m = gl.mrs.get(ref.iid)!;
|
||||
const before = m.mergeStatus ?? 'mergeable';
|
||||
if (gl.recheckTo) m.mergeStatus = gl.recheckTo;
|
||||
return before;
|
||||
},
|
||||
mergeMr: async (ref, sha) => {
|
||||
const m = gl.mrs.get(ref.iid)!;
|
||||
if (m.sha !== sha) throw new Error('409 SHA does not match HEAD of source branch');
|
||||
@@ -411,6 +421,34 @@ test('undo inside the grace period drops the Gas; a new commit drops it too', as
|
||||
assert.ok(w.gl.sent.some((t) => t.includes('Gas api !20 batal: ada commit baru')));
|
||||
});
|
||||
|
||||
test('Gas waits while GitLab has not computed mergeability, asking it to recheck', async () => {
|
||||
const { w, a } = await readyAjuan();
|
||||
w.gl.mrs.get(20)!.mergeStatus = 'unchecked';
|
||||
decide(w.store, a.id, 'gas', 'sen', { sha: 'g1' }, T0);
|
||||
await w.hub.tick(T0 + 16_000);
|
||||
assert.deepEqual(w.gl.rechecks, [20], 'asks GitLab once');
|
||||
assert.deepEqual(w.gl.merges, [], 'does not merge on the first pass');
|
||||
assert.equal(w.store.ajuanById(a.id).decision, 'gas', 'keeps the decision while waiting');
|
||||
assert.ok(!w.gl.sent.some((t) => t.includes('tidak dijalankan')));
|
||||
await w.hub.tick(T0 + 21_000);
|
||||
assert.deepEqual(w.gl.merges, [{ iid: 20, sha: 'g1' }]);
|
||||
assert.deepEqual(w.gl.rechecks, [20]);
|
||||
});
|
||||
|
||||
test('Gas gives up when GitLab stays unchecked, re-asking every 30 seconds', async () => {
|
||||
const { w, a } = await readyAjuan();
|
||||
w.gl.mrs.get(20)!.mergeStatus = 'unchecked';
|
||||
w.gl.recheckTo = null;
|
||||
decide(w.store, a.id, 'gas', 'sen', { sha: 'g1' }, T0);
|
||||
for (let t = T0 + 16_000; t < T0 + 15_000 + 120_000; t += 5_000) await w.hub.tick(t);
|
||||
assert.equal(w.gl.rechecks.length, 4);
|
||||
assert.equal(w.store.ajuanById(a.id).decision, 'gas');
|
||||
await w.hub.tick(T0 + 15_000 + 120_000);
|
||||
assert.deepEqual(w.gl.merges, []);
|
||||
assert.equal(w.store.ajuanById(a.id).decision, null);
|
||||
assert.ok(w.gl.sent.some((t) => t.includes('tidak dijalankan: GitLab masih unchecked setelah 2 menit')));
|
||||
});
|
||||
|
||||
test('the Hub checks GitLab again before merging, and dry mode stops before the merge', async () => {
|
||||
const { w, a } = await readyAjuan();
|
||||
w.gl.mrs.get(20)!.mergeStatus = 'conflict';
|
||||
|
||||
Reference in New Issue
Block a user