diff options
author | Amine Hilaly <hilalyamine@gmail.com> | 2019-07-17 22:41:42 +0200 |
---|---|---|
committer | Amine Hilaly <hilalyamine@gmail.com> | 2019-07-23 17:18:04 +0200 |
commit | ce3a2788ab3bc9f205bcc27b03355155d641c2f4 (patch) | |
tree | 6565bce7af28395e0a244e363b387865bc85e557 /bridge | |
parent | 05a3aec1a89f1b8c56a464558bbe39f96a42b267 (diff) | |
download | git-bug-ce3a2788ab3bc9f205bcc27b03355155d641c2f4.tar.gz |
bridge/gitlab: fix note error handling bug
bridge/gitlab: remove unused functions
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/gitlab/config.go | 37 | ||||
-rw-r--r-- | bridge/gitlab/gitlab.go | 3 | ||||
-rw-r--r-- | bridge/gitlab/import.go | 2 | ||||
-rw-r--r-- | bridge/gitlab/import_test.go | 6 |
4 files changed, 6 insertions, 42 deletions
diff --git a/bridge/gitlab/config.go b/bridge/gitlab/config.go index 7faddd6d..cac2d91e 100644 --- a/bridge/gitlab/config.go +++ b/bridge/gitlab/config.go @@ -107,21 +107,6 @@ func (*Gitlab) ValidateConfig(conf core.Configuration) error { return nil } -func requestToken(client *gitlab.Client, userID int, name string, scopes ...string) (string, error) { - impToken, _, err := client.Users.CreateImpersonationToken( - userID, - &gitlab.CreateImpersonationTokenOptions{ - Name: &name, - Scopes: &scopes, - }, - ) - if err != nil { - return "", err - } - - return impToken.Token, nil -} - func promptToken() (string, error) { fmt.Println("You can generate a new token by visiting https://gitlab.com/settings/tokens.") fmt.Println("Choose 'Generate new token' and set the necessary access scope for your repository.") @@ -231,28 +216,6 @@ func getValidGitlabRemoteURLs(remotes map[string]string) []string { return urls } -func validateUsername(username string) (bool, int, error) { - // no need for a token for this action - client := buildClient("") - - users, _, err := client.Users.ListUsers(&gitlab.ListUsersOptions{Username: &username}) - if err != nil { - return false, 0, err - } - - if len(users) == 0 { - return false, 0, fmt.Errorf("username not found") - } else if len(users) > 1 { - return false, 0, fmt.Errorf("found multiple matches") - } - - if users[0].Username == username { - return true, users[0].ID, nil - } - - return false, 0, nil -} - func validateProjectURL(url, token string) (bool, int, error) { client := buildClient(token) diff --git a/bridge/gitlab/gitlab.go b/bridge/gitlab/gitlab.go index 7a375d6e..9f5807cd 100644 --- a/bridge/gitlab/gitlab.go +++ b/bridge/gitlab/gitlab.go @@ -1,8 +1,9 @@ package gitlab import ( - "github.com/MichaelMure/git-bug/bridge/core" "github.com/xanzy/go-gitlab" + + "github.com/MichaelMure/git-bug/bridge/core" ) func init() { diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go index d94dbe2e..93ad8570 100644 --- a/bridge/gitlab/import.go +++ b/bridge/gitlab/import.go @@ -137,7 +137,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n } hash, errResolve := b.ResolveOperationWithMetadata(keyGitlabId, id) - if err != nil && err != cache.ErrNoMatchingOp { + if errResolve != cache.ErrNoMatchingOp { return err } diff --git a/bridge/gitlab/import_test.go b/bridge/gitlab/import_test.go index ddf0553e..4a49cfe9 100644 --- a/bridge/gitlab/import_test.go +++ b/bridge/gitlab/import_test.go @@ -6,15 +6,15 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/MichaelMure/git-bug/bridge/core" "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/cache" "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/repository" "github.com/MichaelMure/git-bug/util/interrupt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - //_ "github.com/motemen/go-loghttp/global" ) func TestImport(t *testing.T) { |