aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/gitlab')
-rw-r--r--bridge/gitlab/config.go17
-rw-r--r--bridge/gitlab/export.go3
-rw-r--r--bridge/gitlab/import.go2
3 files changed, 17 insertions, 5 deletions
diff --git a/bridge/gitlab/config.go b/bridge/gitlab/config.go
index dfac4c54..4a714d09 100644
--- a/bridge/gitlab/config.go
+++ b/bridge/gitlab/config.go
@@ -3,7 +3,6 @@ package gitlab
import (
"fmt"
"net/url"
- "path"
"regexp"
"strconv"
"strings"
@@ -32,7 +31,7 @@ func (g *Gitlab) ValidParams() map[string]interface{} {
}
}
-func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (core.Configuration, error) {
+func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams, interactive bool) (core.Configuration, error) {
var err error
var baseUrl string
@@ -40,6 +39,9 @@ func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor
case params.BaseURL != "":
baseUrl = params.BaseURL
default:
+ if !interactive {
+ return nil, fmt.Errorf("Non-interactive-mode is active. Please specify the gitlab instance URL via the --base-url option.")
+ }
baseUrl, err = input.PromptDefault("Gitlab server URL", "URL", defaultBaseURL, input.Required, input.IsURL)
if err != nil {
return nil, errors.Wrap(err, "base url prompt")
@@ -54,6 +56,9 @@ func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor
projectURL = params.URL
default:
// terminal prompt
+ if !interactive {
+ return nil, fmt.Errorf("Non-interactive-mode is active. Please specify the gitlab project URL via the --url option.")
+ }
projectURL, err = promptProjectURL(repo, baseUrl)
if err != nil {
return nil, errors.Wrap(err, "url prompt")
@@ -89,6 +94,9 @@ func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor
cred = token
default:
if params.Login == "" {
+ if !interactive {
+ return nil, fmt.Errorf("Non-interactive-mode is active. Please specify the login name via the --login option.")
+ }
// TODO: validate username
login, err = input.Prompt("Gitlab login", "login", input.Required)
} else {
@@ -98,6 +106,9 @@ func (g *Gitlab) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor
if err != nil {
return nil, err
}
+ if !interactive {
+ return nil, fmt.Errorf("Non-interactive-mode is active. Please specify the access token via the --token option.")
+ }
cred, err = promptTokenOptions(repo, login, baseUrl)
if err != nil {
return nil, err
@@ -183,7 +194,7 @@ func promptTokenOptions(repo repository.RepoKeyring, login, baseUrl string) (aut
}
func promptToken(baseUrl string) (*auth.Token, error) {
- fmt.Printf("You can generate a new token by visiting %s.\n", path.Join(baseUrl, "profile/personal_access_tokens"))
+ fmt.Printf("You can generate a new token by visiting %s.\n", strings.TrimSuffix(baseUrl, "/")+"/-/profile/personal_access_tokens")
fmt.Println("Choose 'Create personal access token' and set the necessary access scope for your repository.")
fmt.Println()
fmt.Println("'api' access scope: to be able to make api calls")
diff --git a/bridge/gitlab/export.go b/bridge/gitlab/export.go
index 9c3864ec..e6587eba 100644
--- a/bridge/gitlab/export.go
+++ b/bridge/gitlab/export.go
@@ -525,10 +525,11 @@ func updateGitlabIssueTitle(ctx context.Context, gc *gitlab.Client, repositoryID
func updateGitlabIssueLabels(ctx context.Context, gc *gitlab.Client, repositoryID string, issueID int, labels []string) error {
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()
+ gitlabLabels := gitlab.Labels(labels)
_, _, err := gc.Issues.UpdateIssue(
repositoryID, issueID,
&gitlab.UpdateIssueOptions{
- Labels: labels,
+ Labels: &gitlabLabels,
},
gitlab.WithContext(ctx),
)
diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go
index 98322528..879ef102 100644
--- a/bridge/gitlab/import.go
+++ b/bridge/gitlab/import.go
@@ -347,7 +347,7 @@ func (gi *gitlabImporter) ensurePerson(repo *cache.RepoCache, id int) (*cache.Id
return nil, err
}
- user, _, err := gi.client.Users.GetUser(id)
+ user, _, err := gi.client.Users.GetUser(id, gitlab.GetUsersOptions{})
if err != nil {
return nil, err
}