Skip to content

Instantly share code, notes, and snippets.

@Seminioni
Created June 8, 2018 12:55
Show Gist options
  • Save Seminioni/c325893d9a2c14f785b47640448387cd to your computer and use it in GitHub Desktop.
Save Seminioni/c325893d9a2c14f785b47640448387cd to your computer and use it in GitHub Desktop.
semrush test function
function badCommitFinder(list, item) {
let low = 0;
let high = list.length - 1;
while (low <= high) {
const mid = (low + high) / 2 | 0;
const guess = list[mid];
if (guess === item) {
return mid;
}
if (guess > item) {
high = mid - 1;
} else {
low = mid + 1;
}
}
return new Error('Коммит не найден :с')
}
const numbers = [1, 3, 5, 7, 9, 11, 14, 18, 99]
console.log(badCommitFinder(numbers, 9))
/* https://medium.com/@msanford/finding-breaking-commits-with-git-bisect-dfc55833859
Руководствуяюсь этой статьёй по поиску "плохого" коммита, можно сделать вывод, что git bisect использует внутри себя binary search. Binary search я написал, а вот как конкретно это реализуется в рамках git'a -- не знаю.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment