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:
18
packages/dashboard/app/components/githubTracking.ts
Normal file
18
packages/dashboard/app/components/githubTracking.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user