Cleaner way to remove the username from the git clone URL
This commit is contained in:
parent
be1b75fd45
commit
1152e430c4
1 changed files with 8 additions and 9 deletions
|
@ -154,9 +154,9 @@ func (c *client) Repo(u *model.User, owner, name string) (*model.Repo, error) {
|
||||||
|
|
||||||
client := NewClientWithToken(&c.Consumer, u.Token)
|
client := NewClientWithToken(&c.Consumer, u.Token)
|
||||||
|
|
||||||
url := fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s", c.URL, owner, name)
|
urlString := fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s", c.URL, owner, name)
|
||||||
|
|
||||||
response, err := client.Get(url)
|
response, err := client.Get(urlString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
@ -178,13 +178,12 @@ func (c *client) Repo(u *model.User, owner, name string) (*model.Repo, error) {
|
||||||
|
|
||||||
for _, item := range bsRepo.Links.Clone {
|
for _, item := range bsRepo.Links.Clone {
|
||||||
if item.Name == "http" {
|
if item.Name == "http" {
|
||||||
//TODO sdhould find a clean way to do this
|
uri, err := url.Parse(item.Href)
|
||||||
//We are removing the username out of the link to allow for Netrc to work
|
if err != nil {
|
||||||
splitUrl := strings.SplitAfterN(item.Href,"@",2)
|
return err
|
||||||
splitProtocal := strings.SplitAfterN(splitUrl[0],"//",2)
|
}
|
||||||
cleanUrl := fmt.Sprintf("%s%s",splitProtocal[0], splitUrl[1])
|
uri.User = nil
|
||||||
|
repo.Clone = uri.String()
|
||||||
repo.Clone = cleanUrl
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, item := range bsRepo.Links.Self {
|
for _, item := range bsRepo.Links.Self {
|
||||||
|
|
Loading…
Reference in a new issue