feat(FN-3918): restore github tracking regex helper and tests

Restores a local GitHub tracking regex helper in the dashboard and adds regression tests to prevent future regressions. The feature restores functionality that was previously removed, with tests covering the helper's behavior.

Fusion-Task-Id: FN-3918
This commit is contained in:
Fusion
2026-05-10 04:21:50 -07:00
committed by gsxdsm
parent 956a4af940
commit 7850edfcb0
2 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import type { GlobalSettings, ProjectSettings } from "@fusion/core";
export const REPO_OVERRIDE_RE = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
function normalizeRepoValue(value: string | null | undefined): string {
const trimmed = value?.trim() ?? "";
return REPO_OVERRIDE_RE.test(trimmed) ? trimmed : "";
}
export function resolveEffectiveGithubRepoDefault(
projectSettings?: Pick<ProjectSettings, "githubTrackingDefaultRepo"> | null,
globalSettings?: Pick<GlobalSettings, "githubTrackingDefaultRepo"> | null,
): string {
const projectRepo = normalizeRepoValue(projectSettings?.githubTrackingDefaultRepo);
if (projectRepo) return projectRepo;
return normalizeRepoValue(globalSettings?.githubTrackingDefaultRepo);
}