refactor(FN-1288): consolidate GitHub remote parsing in @fusion/core
- Replace dashboard calls to local getCurrentGitHubRepo helpers with getCurrentRepo from @fusion/core - Update engine scheduler PR-monitor startup paths to use shared core repo resolution - Remove duplicated remote parsing implementations from dashboard and engine packages - Mark gap analysis finding 6.3 as resolved after centralizing parsing logic
This commit is contained in:
@@ -2344,41 +2344,3 @@ export function parseGitHubBadgeUrl(url: string): { owner: string; repo: string
|
||||
return { owner: parsed.owner, repo: parsed.repo };
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract owner/repo from a GitHub remote URL or return null if not a GitHub remote.
|
||||
* @deprecated Use parseRepoFromRemote from gh-cli.ts instead
|
||||
*/
|
||||
export function parseGitHubRemote(remoteUrl: string): { owner: string; repo: string } | null {
|
||||
// Handle HTTPS: https://github.com/owner/repo.git or https://github.com/owner/repo
|
||||
const httpsMatch = remoteUrl.match(/github\.com\/([^\/]+)\/([^\/\.]+)(?:\.git)?$/);
|
||||
if (httpsMatch) {
|
||||
return { owner: httpsMatch[1], repo: httpsMatch[2] };
|
||||
}
|
||||
|
||||
// Handle SSH: git@github.com:owner/repo.git or git@github.com:owner/repo
|
||||
const sshMatch = remoteUrl.match(/github\.com:([^\/]+)\/([^\/\.]+)(?:\.git)?$/);
|
||||
if (sshMatch) {
|
||||
return { owner: sshMatch[1], repo: sshMatch[2] };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current GitHub remote owner/repo from the git config.
|
||||
* @deprecated Use getCurrentRepo from gh-cli.ts instead
|
||||
*/
|
||||
export function getCurrentGitHubRepo(cwd: string): { owner: string; repo: string } | null {
|
||||
const { execFileSync } = require("node:child_process");
|
||||
try {
|
||||
const remoteUrl = execFileSync("git", ["remote", "get-url", "origin"], {
|
||||
cwd,
|
||||
encoding: "utf-8",
|
||||
stdio: ["pipe", "pipe", "ignore"],
|
||||
}).trim();
|
||||
|
||||
return parseGitHubRemote(remoteUrl);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user