feat(FN-3920): export repo override regex from github-tracking module
Exported the repo override regex from `@fusion/core` for use across packages, replacing an internal import in the dashboard's GitHub tracking component with the public API from core. Tests were updated in both packages to cover the new export. Fusion-Task-Id: FN-3920
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { isValidRepoSlug, parseRepoSlug, resolveTaskGithubTracking } from "../github-tracking.js";
|
||||
import { REPO_OVERRIDE_RE, isValidRepoSlug, parseRepoSlug, resolveTaskGithubTracking } from "../github-tracking.js";
|
||||
|
||||
describe("REPO_OVERRIDE_RE", () => {
|
||||
it("matches valid owner/repo overrides", () => {
|
||||
expect(REPO_OVERRIDE_RE.test("owner/repo")).toBe(true);
|
||||
expect(REPO_OVERRIDE_RE.test("org.name/repo_name-1")).toBe(true);
|
||||
expect(REPO_OVERRIDE_RE.test("owner")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseRepoSlug", () => {
|
||||
it("parses valid owner/repo slugs", () => {
|
||||
|
||||
@@ -14,17 +14,16 @@ export interface ResolvedTaskGithubTracking {
|
||||
};
|
||||
}
|
||||
|
||||
export const REPO_OVERRIDE_RE = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
|
||||
|
||||
function parseRepoSlugCandidate(input: unknown): RepoSlug | null {
|
||||
if (typeof input !== "string") return null;
|
||||
const trimmed = input.trim();
|
||||
if (!trimmed) return null;
|
||||
|
||||
const parts = trimmed.split("/");
|
||||
if (parts.length !== 2) return null;
|
||||
const [owner, repo] = parts;
|
||||
if (!owner || !repo) return null;
|
||||
if (/\s/.test(owner) || /\s/.test(repo)) return null;
|
||||
if (!REPO_OVERRIDE_RE.test(trimmed)) return null;
|
||||
|
||||
const [owner, repo] = trimmed.split("/");
|
||||
return { owner, repo };
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ export {
|
||||
type GhError,
|
||||
} from "./gh-cli.js";
|
||||
export {
|
||||
REPO_OVERRIDE_RE,
|
||||
parseRepoSlug,
|
||||
isValidRepoSlug,
|
||||
resolveTaskGithubTracking,
|
||||
|
||||
Reference in New Issue
Block a user