Skip to content

Commit

Permalink
Bitbucket Cloud: Change platform indicator from DANGER_BITBUCKETCLOUD…
Browse files Browse the repository at this point in the history
…_UUID to DANGER_BITBUCKETCLOUD_OAUTH_KEY OR DANGER_BITBUCKETCLOUD_USERNAME
  • Loading branch information
HelloCore committed Dec 6, 2019
1 parent 8368d7e commit b639246
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion source/ci_source/ci_source_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function getPullRequestIDForBranch(metadata: RepoMetaData, env: Env
}
return 0
}
if (process.env["DANGER_BITBUCKETCLOUD_UUID"]) {
if (process.env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] || process.env["DANGER_BITBUCKETCLOUD_USERNAME"]) {
const api = new BitBucketCloudAPI(metadata, bitbucketCloudCredentialsFromEnv(env))
const prs = await api.getPullRequestsFromBranch(branch)
if (prs.length) {
Expand Down
5 changes: 3 additions & 2 deletions source/commands/danger-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ program
if (
!process.env["DANGER_GITHUB_API_TOKEN"] &&
!process.env["DANGER_BITBUCKETSERVER_HOST"] &&
!process.env["DANGER_BITBUCKETCLOUD_UUID"] &&
!process.env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] &&
!process.env["DANGER_BITBUCKETCLOUD_USERNAME"] &&
!gitLabApiCredentials.token
) {
log("")
log(
" You don't have a DANGER_GITHUB_API_TOKEN/DANGER_GITLAB_API_TOKEN/DANGER_BITBUCKETCLOUD_UUID set up, this is optional, but TBH, you want to do this."
" You don't have a DANGER_GITHUB_API_TOKEN/DANGER_GITLAB_API_TOKEN/DANGER_BITBUCKETCLOUD_OAUTH_KEY/DANGER_BITBUCKETCLOUD_USERNAME set up, this is optional, but TBH, you want to do this."
)
log(" Check out: http://danger.systems/js/guides/the_dangerfile.html#working-on-your-dangerfile")
log("")
Expand Down
6 changes: 5 additions & 1 deletion source/platforms/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ export function getPlatformForEnv(env: Env, source: CISource): Platform {
}

// Bitbucket Cloud
if (env["DANGER_BITBUCKETCLOUD_UUID"] || env["DANGER_PR_PLATFORM"] === BitBucketCloud.name) {
if (
env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] ||
env["DANGER_BITBUCKETCLOUD_USERNAME"] ||
env["DANGER_PR_PLATFORM"] === BitBucketCloud.name
) {
const api = new BitBucketCloudAPI(
{
pullRequestID: source.pullRequestID,
Expand Down
6 changes: 3 additions & 3 deletions source/runner/Executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export class Executor {
let comment
if (process.env["DANGER_BITBUCKETSERVER_HOST"]) {
comment = bitbucketServerTemplate(dangerID, mergedResults, commitID)
} else if (process.env["DANGER_BITBUCKETCLOUD_UUID"]) {
} else if (process.env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] || process.env["DANGER_BITBUCKETCLOUD_USERNAME"]) {
comment = bitbucketCloudTemplate(dangerID, mergedResults, commitID)
} else {
comment = githubResultsTemplate(dangerID, mergedResults, commitID)
Expand Down Expand Up @@ -414,7 +414,7 @@ export class Executor {
let comment
if (process.env["DANGER_BITBUCKETSERVER_HOST"]) {
comment = bitbucketServerInlineTemplate(this.options.dangerID, results, inlineResults.file, inlineResults.line)
} else if (process.env["DANGER_BITBUCKETCLOUD_UUID"]) {
} else if (process.env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] || process.env["DANGER_BITBUCKETCLOUD_USERNAME"]) {
comment = bitbucketCloudInlineTemplate(this.options.dangerID, results, inlineResults.file, inlineResults.line)
} else {
comment = githubResultsInlineTemplate(this.options.dangerID, results, inlineResults.file, inlineResults.line)
Expand Down Expand Up @@ -445,7 +445,7 @@ const messageForResults = (results: DangerResults) => {
} else {
if (process.env["DANGER_BITBUCKETSERVER_HOST"]) {
return bitbucketMessageForResultWithIssues
} else if (process.env["DANGER_BITBUCKETCLOUD_UUID"]) {
} else if (process.env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] || process.env["DANGER_BITBUCKETCLOUD_USERNAME"]) {
return bitbucketCloudMessageForResultWithIssues
} else {
return githubMessageForResultWithIssues
Expand Down
4 changes: 2 additions & 2 deletions source/runner/jsonToDSL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const jsonToDSL = async (dsl: DangerDSLJSONType, source: CISource): Promi
git = await localPlatform.getPlatformGitRepresentation()
} else if (process.env["DANGER_BITBUCKETSERVER_HOST"]) {
git = bitBucketServerGitDSL(bitbucket_server!, dsl.git, api as BitBucketServerAPI)
} else if (process.env["DANGER_BITBUCKETCLOUD_UUID"]) {
} else if (process.env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] || process.env["DANGER_BITBUCKETCLOUD_USERNAME"]) {
git = bitBucketCloudGitDSL(bitbucket_cloud!, dsl.git, api as BitBucketCloudAPI)
} else if (process.env["DANGER_GITLAB_API_TOKEN"]) {
git = gitLabGitDSL(gitlab!, dsl.git)
Expand Down Expand Up @@ -72,7 +72,7 @@ const apiForDSL = (dsl: DangerDSLJSONType): OctoKit | BitBucketServerAPI | GitLa
return new BitBucketServerAPI(dsl.bitbucket_server!.metadata, bitbucketServerRepoCredentialsFromEnv(process.env))
}

if (process.env["DANGER_BITBUCKETCLOUD_UUID"]) {
if (process.env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] || process.env["DANGER_BITBUCKETCLOUD_USERNAME"]) {
return new BitBucketCloudAPI(dsl.bitbucket_cloud!.metadata, bitbucketCloudCredentialsFromEnv(process.env))
}

Expand Down

0 comments on commit b639246

Please sign in to comment.