add empty value checking for Bitbucket provider's setTeam and setRepository

This commit is contained in:
YusukeIwaki 2019-09-08 01:16:57 +09:00
parent 44cdcc79c3
commit e1984b71a2
2 changed files with 4 additions and 9 deletions

View File

@ -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"
}
}

View File

@ -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)