Skip to content

Commit 134332d

Browse files
committed
Fix bug in bisect tool
1 parent 5a944b5 commit 134332d

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

website/static/js/page/contributor-guide/bisect-tool.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,36 @@ document.addEventListener("DOMContentLoaded", () => {
214214
commits = fetched;
215215
}
216216

217+
async function extendCommitsForward() {
218+
if (commits.length === 0) return false;
219+
220+
const newest = commits[commits.length - 1];
221+
const since = new Date(newest.date.getTime() + 1000).toISOString();
222+
223+
let /** @type {any[]} */ allRaw = [];
224+
let page = 1;
225+
226+
while (true) {
227+
const raw = await fetchCommitList(since, undefined, page);
228+
if (!raw || raw.length === 0) break;
229+
allRaw = allRaw.concat(raw);
230+
if (raw.length < 100) break;
231+
page++;
232+
}
233+
234+
if (allRaw.length === 0) return false;
235+
236+
let fetched = parseCommits(allRaw);
237+
fetched.reverse();
238+
239+
const existingShas = new Set(commits.map((c) => c.sha));
240+
fetched = fetched.filter((c) => !existingShas.has(c.sha));
241+
if (fetched.length === 0) return false;
242+
243+
commits = [...commits, ...fetched];
244+
return true;
245+
}
246+
217247
async function extendCommitsBackward() {
218248
if (commits.length === 0) return false;
219249

@@ -340,8 +370,9 @@ document.addEventListener("DOMContentLoaded", () => {
340370
badIndex = currentIndex;
341371
boundarySearching = true;
342372
} else {
343-
// Absent at starting commit. The newest commit should have it (user assumes master has it).
373+
// Absent at starting commit, so the issue was introduced more recently. Extend the commit list forward (towards HEAD) before narrowing.
344374
goodIndex = currentIndex;
375+
await extendCommitsForward();
345376
badIndex = commits.length - 1;
346377
bisectPhase = "binary";
347378
}

0 commit comments

Comments
 (0)