diff options
author | Michael Muré <batolettre@gmail.com> | 2019-12-10 21:13:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-10 21:13:54 +0100 |
commit | e96d8e6771086e20639a16abf6af30f2faa006a0 (patch) | |
tree | 606c0d2897c06e4ca226d377917437c62fdd1560 /bridge/gitlab/export.go | |
parent | ef6801a37f75fbc5f65b0a5db194b7f88b439e7b (diff) | |
parent | f6b4830c0b68f3b5c616236bc9d51943765c8b4a (diff) | |
download | git-bug-e96d8e6771086e20639a16abf6af30f2faa006a0.tar.gz |
Merge pull request #274 from MichaelMure/gitlab-bridge
bridge/gitlab: support self-hosted GitLab instance
Diffstat (limited to 'bridge/gitlab/export.go')
-rw-r--r-- | bridge/gitlab/export.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/bridge/gitlab/export.go b/bridge/gitlab/export.go index 373cf637..d42ef1cd 100644 --- a/bridge/gitlab/export.go +++ b/bridge/gitlab/export.go @@ -62,7 +62,11 @@ func (ge *gitlabExporter) cacheAllClient(repo repository.RepoConfig) error { for _, cred := range creds { if _, ok := ge.identityClient[cred.UserId()]; !ok { - client := buildClient(creds[0].(*auth.Token)) + client, err := buildClient(ge.conf[keyGitlabBaseUrl], creds[0].(*auth.Token)) + if err != nil { + return err + } + ge.identityClient[cred.UserId()] = client } } @@ -133,6 +137,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc var err error var bugGitlabID int var bugGitlabIDString string + var GitlabBaseUrl string var bugCreationId string // Special case: @@ -153,6 +158,12 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc // get gitlab bug ID gitlabID, ok := snapshot.GetCreateMetadata(metaKeyGitlabId) if ok { + gitlabBaseUrl, ok := snapshot.GetCreateMetadata(metaKeyGitlabBaseUrl) + if ok && gitlabBaseUrl != ge.conf[gitlabBaseUrl] { + out <- core.NewExportNothing(b.Id(), "skipping issue imported from another Gitlab instance") + return + } + projectID, ok := snapshot.GetCreateMetadata(metaKeyGitlabProject) if !ok { err := fmt.Errorf("expected to find gitlab project id") @@ -199,6 +210,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc metaKeyGitlabId: idString, metaKeyGitlabUrl: url, metaKeyGitlabProject: ge.repositoryID, + metaKeyGitlabBaseUrl: GitlabBaseUrl, }, ) if err != nil { |