Fix WriteGitCreds for BitBucket

The default BitbucketBaseURL value if not set by the user is
"https://api.bitbucket.org" which does not actually work with git.
This commit is contained in:
Andrew Jeffree
2019-12-18 10:01:06 +11:00
parent 7ea9b4da5e
commit 27c13036a0

View File

@@ -179,7 +179,13 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
}
}
if userConfig.BitbucketUser != "" {
if err := events.WriteGitCreds(userConfig.BitbucketUser, userConfig.BitbucketToken, userConfig.BitbucketBaseURL, home, logger); err != nil {
// The default BitbucketBaseURL is https://api.bitbucket.org which can't actually be used for git
// so we overide it here only if it's that to be bitbucket.org
bitbucketBaseURL := userConfig.BitbucketBaseURL
if bitbucketBaseURL == "https://api.bitbucket.org" {
bitbucketBaseURL = "bitbucket.org"
}
if err := events.WriteGitCreds(userConfig.BitbucketUser, userConfig.BitbucketToken, bitbucketBaseURL, home, logger); err != nil {
return nil, err
}
}