diff options
author | Amine Hilaly <hilalyamine@gmail.com> | 2019-07-22 18:56:14 +0200 |
---|---|---|
committer | Amine Hilaly <hilalyamine@gmail.com> | 2019-07-23 17:18:04 +0200 |
commit | ece2cb126293361212d7673fea976876af7b811b (patch) | |
tree | f0ad5735e51719f5b41099f379ff1f2ee9446b8b /bridge/gitlab/config.go | |
parent | 54dd81e3376ef557b5be3aa642accec219005949 (diff) | |
download | git-bug-ece2cb126293361212d7673fea976876af7b811b.tar.gz |
bridge/gitlab: improve tests and errors
bridge/gitlab: global fixes
Diffstat (limited to 'bridge/gitlab/config.go')
-rw-r--r-- | bridge/gitlab/config.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/bridge/gitlab/config.go b/bridge/gitlab/config.go index efef5993..a375bab2 100644 --- a/bridge/gitlab/config.go +++ b/bridge/gitlab/config.go @@ -3,7 +3,7 @@ package gitlab import ( "bufio" "fmt" - neturl "net/url" + "net/url" "os" "regexp" "strconv" @@ -41,13 +41,13 @@ func (*Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams) ( // remote suggestions remotes, err := repo.GetRemotes() if err != nil { - return nil, err + return nil, errors.Wrap(err, "getting remotes") } // terminal prompt url, err = promptURL(remotes) if err != nil { - return nil, err + return nil, errors.Wrap(err, "url prompt") } } @@ -57,7 +57,7 @@ func (*Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams) ( } else { token, err = promptToken() if err != nil { - return nil, err + return nil, errors.Wrap(err, "token prompt") } } @@ -65,7 +65,7 @@ func (*Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams) ( // validate project url and get it ID ok, id, err := validateProjectURL(url, token) if err != nil { - return nil, err + return nil, errors.Wrap(err, "project validation") } if !ok { return nil, fmt.Errorf("invalid project id or wrong token scope") @@ -180,15 +180,14 @@ func promptURL(remotes map[string]string) (string, error) { } } -func getProjectPath(url string) (string, error) { - cleanUrl := strings.TrimSuffix(url, ".git") +func getProjectPath(projectUrl string) (string, error) { + cleanUrl := strings.TrimSuffix(projectUrl, ".git") cleanUrl = strings.Replace(cleanUrl, "git@", "https://", 1) - objectUrl, err := neturl.Parse(cleanUrl) + objectUrl, err := url.Parse(cleanUrl) if err != nil { - return "", err + return "", ErrBadProjectURL } - fmt.Println(objectUrl.Path) return objectUrl.Path[1:], nil } |