(input: string)
| 23 | * @returns The link and branch if the input is a valid git repository url, otherwise undefined. |
| 24 | */ |
| 25 | export function extractGitInfo(input: string): {link: string; branch?: string} | undefined { |
| 26 | const gitLinkMatch = input.match(githubLinkRegex); |
| 27 | const bitBucketLinkMatch = input.match(bitbucketLinkRegex); |
| 28 | const sshMatch = input.match(sshRegex); |
| 29 | if (!gitLinkMatch && !sshMatch && !bitBucketLinkMatch) { |
| 30 | return undefined; |
| 31 | } |
| 32 | const {branch, domain, repository} = gitLinkMatch?.groups || bitBucketLinkMatch?.groups || {}; |
| 33 | const link = sshMatch |
| 34 | ? input |
| 35 | : `https:${ |
| 36 | gitLinkMatch ? `//github.com` : bitBucketLinkMatch ? `//bitbucket.org` : undefined |
| 37 | }/${domain}/${repository}`; |
| 38 | return {link, branch}; |
| 39 | } |
| 40 | |
| 41 | // improve project info from the graph package json |
| 42 | export function improveProjectInfo(subgraphDir: string, subgraphManifest: SubgraphProject): void { |
no outgoing calls
no test coverage detected