Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/github/backfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export async function backfillRegisteredRepositories(
env: Env,
options: { repoFullName?: string; limits?: Partial<BackfillLimits>; requestedBy?: string; force?: boolean; mode?: BackfillMode } = {},
): Promise<BackfillRegisteredReposResult> {
const repositories = (await listRepositories(env)).filter((repo) => repo.isRegistered && (!options.repoFullName || repo.fullName === options.repoFullName));
const repositories = (await listRepositories(env)).filter((repo) => repo.isInstalled && (!options.repoFullName || repo.fullName === options.repoFullName));
const mode = options.mode ?? "light";
const limits = { ...DEFAULT_LIMITS, ...MODE_LIMITS[mode], ...(options.limits ?? {}) };
const repoResults = await mapWithConcurrency(repositories, limits.repoConcurrency, async (repo): Promise<RepoBackfillResult> => {
Expand Down Expand Up @@ -470,7 +470,7 @@ export async function enqueueRepositoryOpenDataBackfill(
options: { repoFullName: string; requestedBy: "schedule" | "api" | "test"; mode?: BackfillMode; force?: boolean },
): Promise<{ ok: true; repoFullName: string; status: "queued" | "skipped"; totals?: RepoGithubTotalsSnapshotRecord; warnings: string[] }> {
const repo = await getRepository(env, options.repoFullName);
if (!repo?.isRegistered) return { ok: true, repoFullName: options.repoFullName, status: "skipped", warnings: ["Repository is not registered for Gittensory backfill."] };
if (!repo?.isInstalled) return { ok: true, repoFullName: options.repoFullName, status: "skipped", warnings: ["Repository is not installed for Gittensory backfill."] };
const mode = options.mode ?? "light";
const settings = await resolveRepositorySettings(env, repo.fullName);
if (!settings.backfillEnabled) return { ok: true, repoFullName: repo.fullName, status: "skipped", warnings: ["Backfill is disabled for this repository."] };
Expand Down
5 changes: 5 additions & 0 deletions test/unit/backfill-file-hydration-scoping.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
upsertPullRequestDetailSyncState,
upsertPullRequestFile,
upsertPullRequestFromGitHub,
upsertRepositoryFromGitHub,
} from "../../src/db/repositories";
import { backfillOpenPullRequestDetails, backfillRegisteredRepositories, backfillRepositorySegment, refreshPullRequestDetails } from "../../src/github/backfill";
import { clearInstallationTokenCacheForTest } from "../../src/github/app";
import { clearGitHubResponseCacheForTest } from "../../src/github/client";
import { renderMetrics, resetMetrics } from "../../src/selfhost/metrics";
import { normalizeRegistryPayload } from "../../src/registry/normalize";
Expand All @@ -18,6 +20,7 @@ import { createTestEnv } from "../helpers/d1";
describe("GitHub PR file hydration scoping (#audit-rate-headroom)", () => {
afterEach(() => {
clearGitHubResponseCacheForTest();
clearInstallationTokenCacheForTest();
resetMetrics();
vi.unstubAllGlobals();
});
Expand Down Expand Up @@ -462,6 +465,8 @@ describe("GitHub PR file hydration scoping (#audit-rate-headroom)", () => {
it("populates the head-SHA snapshot from the monolithic backfillRegisteredRepositories path so a later run reuses it (regression: the /run admin endpoint's PR-detail loop must WRITE the cache it reads)", async () => {
const env = createTestEnv({ GITHUB_PUBLIC_TOKEN: "public-token" });
await seedRegisteredRepo(env);
// backfillRegisteredRepositories now gates on isInstalled, not isRegistered (#5021).
await upsertRepositoryFromGitHub(env, { name: "gittensory", full_name: "JSONbored/gittensory", private: true, owner: { login: "JSONbored" } }, 456);
let filesCallCount = 0;
stubFetchTracking((url) => {
if (url.endsWith("/repos/JSONbored/gittensory")) return Response.json({ name: "gittensory", full_name: "JSONbored/gittensory", default_branch: "main", owner: { login: "JSONbored" } });
Expand Down
Loading