MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / repoRefFromRoute

Function repoRefFromRoute

website/src/lib/repo-provider.ts:83–113  ·  view source on GitHub ↗
(
  provider: RepoProvider | undefined,
  owner: string | undefined,
  repo: string | undefined,
  gitlabSplat?: string
)

Source from the content-addressed store, hash-verified

81
82/** Build a RepoRef from route parameters. */
83export function repoRefFromRoute(
84 provider: RepoProvider | undefined,
85 owner: string | undefined,
86 repo: string | undefined,
87 gitlabSplat?: string
88): RepoRef | null {
89 if (provider === "gitlab") {
90 const fullPath = cleanRepoPathSegment(gitlabSplat || "");
91 if (!fullPath) return null;
92 const parts = fullPath.split("/").filter(Boolean);
93 if (parts.length < 2) return null;
94 const repoName = parts[parts.length - 1];
95 const ownerPath = parts.slice(0, -1).join("/");
96 return {
97 provider: "gitlab",
98 owner: ownerPath,
99 repo: repoName,
100 fullPath,
101 host: GITLAB_HOST,
102 };
103 }
104
105 if (!owner || !repo) return null;
106 return {
107 provider: provider === "github" ? "github" : "github",
108 owner,
109 repo,
110 fullPath: `${owner}/${repo}`,
111 host: GITHUB_HOST,
112 };
113}
114
115/** Guess provider from partial user input (URL or shorthand). Defaults to GitHub. */
116export function detectProviderFromInput(input: string): RepoProvider {

Callers 1

ExploreFunction · 0.90

Calls 1

cleanRepoPathSegmentFunction · 0.85

Tested by

no test coverage detected