Skip to content

Commit d73e56a

Browse files
committed
feat: add skip feature for bisection(#950)
Bias was set to better choose an appropriate version to test based on the skipping algorithm in git bisection. Because RunnableVersion does not indicate whether a specific revision has been skipped, it will choose a random version regardless of its skip status.
1 parent 72117c8 commit d73e56a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/renderer/bisect.ts

+12
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ export class Bisector {
5353
}
5454
}
5555

56+
public skip() {
57+
const prevPivot = this.pivot;
58+
this.pivot =
59+
Math.floor(
60+
Math.pow(Math.random(), 1.5) * (this.maxRev - this.minRev + 1),
61+
) + this.minRev;
62+
63+
if (this.pivot === prevPivot && this.pivot > this.minRev) this.pivot--;
64+
65+
return this.revList[this.pivot];
66+
}
67+
5668
private calculatePivot() {
5769
this.pivot = Math.floor((this.maxRev - this.minRev) / 2);
5870
}

src/renderer/components/commands-bisect.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ export const BisectHandler = observer(
5151
}
5252
}
5353

54+
private skipBisect() {
55+
window.app.runner.stop();
56+
const { appState } = this.props;
57+
const response = appState.Bisector!.skip();
58+
59+
appState.setVersion(response.version);
60+
}
61+
5462
private terminateBisect() {
5563
const { appState } = this.props;
5664
appState.Bisector = undefined;
@@ -75,6 +83,14 @@ export const BisectHandler = observer(
7583
onClick={() => this.continueBisect(false)}
7684
disabled={isDownloading}
7785
/>
86+
<Button
87+
icon={'random'}
88+
aria-label={'Skip this commit'}
89+
onClick={() => this.skipBisect()}
90+
disabled={isDownloading}
91+
>
92+
Skip
93+
</Button>
7894
<Button
7995
aria-label={'Cancel bisect'}
8096
icon={'cross'}

0 commit comments

Comments
 (0)