diff --git a/packages/ingest-github/src/githubUrl.ts b/packages/ingest-github/src/githubUrl.ts index f205106..518201d 100644 --- a/packages/ingest-github/src/githubUrl.ts +++ b/packages/ingest-github/src/githubUrl.ts @@ -20,14 +20,15 @@ export interface ParsedRepo { /** * Parses `https://github.com/{owner}/{repo}(/tree/{branch})?` → `{owner, repo, branch?}`. * - * Also accepts `gitlab.com` URLs of the form - * `https://gitlab.com/{owner}/{repo}` so the runner can build a kube-v2 - * `RepoLocation` for GitLab knowledges that route through this pipeline via - * an injected `SourceFactory`. The kernel `RepoLocation` only has a `github` - * provider variant today, so GitLab projects share the github path segment. + * Also accepts `gitlab.com` and `bitbucket.org` URLs of the form + * `https://gitlab.com/{owner}/{repo}` / `https://bitbucket.org/{workspace}/{repoSlug}` + * so the runner can build a kube-v2 `RepoLocation` for GitLab + Bitbucket + * knowledges that route through this pipeline via an injected + * `SourceFactory`. The kernel `RepoLocation` only has a `github` provider + * variant today, so non-GitHub projects share the github path segment. * Subgroup gitlab URLs (`group/sub/project`) collapse to `{ owner: group, * repo: sub }` here — downstream consumers that need the full namespace - * should derive it themselves; the GitLab source-factory does this. + * should derive it themselves; the GitLab / Bitbucket source-factories do this. */ export function parseGithubRepo(repoUrl: string): ParsedRepo | null { if (!repoUrl) { @@ -35,7 +36,11 @@ export function parseGithubRepo(repoUrl: string): ParsedRepo | null { } try { const url = new URL(repoUrl); - if (!url.hostname.endsWith("github.com") && !url.hostname.endsWith("gitlab.com")) { + if ( + !url.hostname.endsWith("github.com") && + !url.hostname.endsWith("gitlab.com") && + !url.hostname.endsWith("bitbucket.org") + ) { return null; } const segments = url.pathname.split("/").filter((s) => s.length > 0); diff --git a/packages/types/src/path-layout.ts b/packages/types/src/path-layout.ts index 495c115..41c11e8 100644 --- a/packages/types/src/path-layout.ts +++ b/packages/types/src/path-layout.ts @@ -102,9 +102,10 @@ export function bytebellPathsFor(home: string, loc: RepoLocation): MetaPathsLayo } /** - * Pure URL parser for GitHub repo URLs. Extracts owner and repo segments, - * tolerating `.git` suffixes and `tree/branch` paths. Returns `null` on any - * input that isn't a GitHub-hosted URL. + * Pure URL parser for GitHub / GitLab / Bitbucket repo URLs. Extracts owner + * and repo segments, tolerating `.git` suffixes and `tree/branch` paths. + * Returns `null` on any input that isn't a github.com / gitlab.com / + * bitbucket.org URL. * * Duplicates the public `parseGithubRepo` from `@bb/ingest-github/githubUrl` * deliberately — kernel-tier code can't import from Domain. The two @@ -116,7 +117,11 @@ export function parseGithubOwnerRepo(repoUrl: string): { owner: string; repo: st } try { const url = new URL(repoUrl); - if (!url.hostname.endsWith("github.com") && !url.hostname.endsWith("gitlab.com")) { + if ( + !url.hostname.endsWith("github.com") && + !url.hostname.endsWith("gitlab.com") && + !url.hostname.endsWith("bitbucket.org") + ) { return null; } const segments = url.pathname.split("/").filter((s) => s.length > 0);