From e1984b71a20424408500682c7b95ef787192e4d3 Mon Sep 17 00:00:00 2001 From: YusukeIwaki Date: Sun, 8 Sep 2019 01:16:57 +0900 Subject: [PATCH] add empty value checking for Bitbucket provider's setTeam and setRepository --- providers/bitbucket.go | 4 ++-- providers/bitbucket_test.go | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/providers/bitbucket.go b/providers/bitbucket.go index 63c1d0f..ba029d3 100644 --- a/providers/bitbucket.go +++ b/providers/bitbucket.go @@ -50,7 +50,7 @@ func NewBitbucketProvider(p *ProviderData) *BitbucketProvider { // SetTeam defines the Bitbucket team the user must be part of func (p *BitbucketProvider) SetTeam(team string) { p.Team = team - if !strings.Contains(p.Scope, "team") { + if team != "" && !strings.Contains(p.Scope, "team") { p.Scope += " team" } } @@ -58,7 +58,7 @@ func (p *BitbucketProvider) SetTeam(team string) { // SetRepository defines the repository the user must have access to func (p *BitbucketProvider) SetRepository(repository string) { p.Repository = repository - if !strings.Contains(p.Scope, "repository") { + if repository != "" && !strings.Contains(p.Scope, "repository") { p.Scope += " repository" } } diff --git a/providers/bitbucket_test.go b/providers/bitbucket_test.go index 585603d..48d32ca 100644 --- a/providers/bitbucket_test.go +++ b/providers/bitbucket_test.go @@ -22,13 +22,8 @@ func testBitbucketProvider(hostname, team string, repository string) *BitbucketP ValidateURL: &url.URL{}, Scope: ""}) - if team != "" { - p.SetTeam(team) - } - - if repository != "" { - p.SetRepository(repository) - } + p.SetTeam(team) + p.SetRepository(repository) if hostname != "" { updateURL(p.Data().LoginURL, hostname)