MCPcopy Index your code
hub / github.com/git-bug/git-bug / getProjectPath

Function getProjectPath

bridge/gitlab/config.go:239–256  ·  view source on GitHub ↗
(baseUrl, projectUrl string)

Source from the content-addressed store, hash-verified

237}
238
239func getProjectPath(baseUrl, projectUrl string) (string, error) {
240 cleanUrl := strings.TrimSuffix(projectUrl, ".git")
241 cleanUrl = strings.Replace(cleanUrl, "git@", "https://", 1)
242 objectUrl, err := url.Parse(cleanUrl)
243 if err != nil {
244 return "", ErrBadProjectURL
245 }
246
247 objectBaseUrl, err := url.Parse(baseUrl)
248 if err != nil {
249 return "", ErrBadProjectURL
250 }
251
252 if objectUrl.Hostname() != objectBaseUrl.Hostname() {
253 return "", fmt.Errorf("base url and project url hostnames doesn't match")
254 }
255 return objectUrl.Path[1:], nil
256}
257
258func getValidGitlabRemoteURLs(repo repository.RepoCommon, baseUrl string) ([]string, error) {
259 remotes, err := repo.GetRemotes()

Callers 3

TestProjectPathFunction · 0.85
getValidGitlabRemoteURLsFunction · 0.85
validateProjectURLFunction · 0.85

Calls 2

ErrorfMethod · 0.80
ParseMethod · 0.65

Tested by 1

TestProjectPathFunction · 0.68