(remoteUrl?: string)
| 8 | |
| 9 | // Helper function to get repo info for responsive display |
| 10 | export function getRepoInfo(remoteUrl?: string): { |
| 11 | repoName: string; |
| 12 | branchName: string | null; |
| 13 | fullPath: string; |
| 14 | isGitRepo: boolean; |
| 15 | } { |
| 16 | let url = remoteUrl ?? ""; |
| 17 | const isGit = isGitRepo(); |
| 18 | let branchName: string | null = null; |
| 19 | |
| 20 | if (!url && isGit) { |
| 21 | const gitUrl = getGitRemoteUrl(); |
| 22 | if (gitUrl) { |
| 23 | url = gitUrl; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | if (!url) { |
| 28 | url = process.cwd(); |
| 29 | } |
| 30 | |
| 31 | // Get branch info if we're in a git repo |
| 32 | if (isGit) { |
| 33 | branchName = getGitBranch(); |
| 34 | } |
| 35 | |
| 36 | // Clean up the URL |
| 37 | const cleanUrl = url |
| 38 | .replace(/\.git$/, "") |
| 39 | .replace(/^(https|http):\/\/.*?\//, ""); |
| 40 | |
| 41 | return { |
| 42 | repoName: cleanUrl, |
| 43 | branchName, |
| 44 | fullPath: url, |
| 45 | isGitRepo: isGit, |
| 46 | }; |
| 47 | } |
| 48 | |
| 49 | // Helper function to get responsive repo URL text based on available width |
| 50 | export function getResponsiveRepoText( |
no test coverage detected