CredentialPatternFromGitURL takes a git remote URL e.g. "https://github.com/cli/cli.git" or "git@github.com:cli/cli.git" and returns the credential pattern that should be used for it.
(gitURL string)
| 121 | // CredentialPatternFromGitURL takes a git remote URL e.g. "https://github.com/cli/cli.git" or |
| 122 | // "git@github.com:cli/cli.git" and returns the credential pattern that should be used for it. |
| 123 | func CredentialPatternFromGitURL(gitURL string) (CredentialPattern, error) { |
| 124 | normalizedURL, err := ParseURL(gitURL) |
| 125 | if err != nil { |
| 126 | return CredentialPattern{}, fmt.Errorf("failed to parse remote URL: %w", err) |
| 127 | } |
| 128 | return CredentialPatternFromHost(normalizedURL.Host), nil |
| 129 | } |
| 130 | |
| 131 | // CredentialPatternFromHost expects host to be in the form "github.com" and returns |
| 132 | // the credential pattern that should be used for it. |