Avoid GitHub self-heal polling without remote
This commit is contained in:
@@ -631,6 +631,30 @@ describe("WorkspaceGitServiceImpl primitive refresh entrypoint", () => {
|
||||
github.dispose?.();
|
||||
});
|
||||
|
||||
test("subscription skips GitHub self-heal polling when the checkout has no GitHub remote", async () => {
|
||||
const retainCurrentPullRequestStatusPoll = vi.fn(() => ({ unsubscribe: vi.fn() }));
|
||||
const github = {
|
||||
...createGitHubServiceStub(),
|
||||
retainCurrentPullRequestStatusPoll,
|
||||
};
|
||||
const getCheckoutStatus = vi.fn(async (cwd: string) =>
|
||||
createCheckoutStatus(cwd, {
|
||||
hasRemote: false,
|
||||
remoteUrl: null,
|
||||
}),
|
||||
);
|
||||
const service = createService({
|
||||
getCheckoutStatus,
|
||||
github,
|
||||
});
|
||||
const subscription = await service.subscribe({ cwd: "/tmp/repo" }, vi.fn());
|
||||
|
||||
expect(retainCurrentPullRequestStatusPoll).not.toHaveBeenCalled();
|
||||
|
||||
subscription.unsubscribe();
|
||||
service.dispose();
|
||||
});
|
||||
|
||||
test("multiple subscribers on the same target share one self-heal timer", async () => {
|
||||
let nowMs = 0;
|
||||
const getCheckoutStatus = vi.fn(async (cwd: string) => createCheckoutStatus(cwd));
|
||||
|
||||
@@ -945,8 +945,14 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
|
||||
return;
|
||||
}
|
||||
|
||||
const headRef = target.latestSnapshot?.git.currentBranch ?? null;
|
||||
if (!headRef || !this.deps.github.retainCurrentPullRequestStatusPoll) {
|
||||
const snapshot = target.latestSnapshot;
|
||||
if (!snapshot || !this.deps.github.retainCurrentPullRequestStatusPoll) {
|
||||
this.stopGitHubPollForTarget(target);
|
||||
return;
|
||||
}
|
||||
|
||||
const headRef = snapshot.git.currentBranch;
|
||||
if (!headRef || !hasGitHubRemoteUrl(snapshot.git.remoteUrl)) {
|
||||
this.stopGitHubPollForTarget(target);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user