Skip to content

Commit

Permalink
Make uuid optional instead
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloCore committed Dec 6, 2019
1 parent 61084fc commit f5ba1a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 4 additions & 6 deletions source/platforms/bitbucket_cloud/BitBucketCloudAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { RepoMetaData } from "../../dsl/BitBucketServerDSL"

export type BitBucketCloudCredentials = {
/** Unique ID for this user, must be wrapped with brackets */
uuid: string
uuid?: string
} & (BitBucketCloudCredentialsOAuth | BitBucketCloudCredentialsPassword)

interface BitBucketCloudCredentialsOAuth {
Expand All @@ -35,8 +35,8 @@ interface BitBucketCloudCredentialsPassword {
}

export function bitbucketCloudCredentialsFromEnv(env: Env): BitBucketCloudCredentials {
const uuid = `${env["DANGER_BITBUCKETCLOUD_UUID"]}`
if (uuid.length > 0) {
const uuid: string | undefined = env["DANGER_BITBUCKETCLOUD_UUID"]
if (uuid != null && uuid.length > 0) {
if (!uuid.startsWith("{") || !uuid.endsWith("}")) {
throw new Error(`DANGER_BITBUCKETCLOUD_UUID must be wraped with brackets`)
}
Expand Down Expand Up @@ -83,9 +83,7 @@ export class BitBucketCloudAPI {
this.fetch = fetch

// Backward compatible,
if (credentials.uuid.length > 0) {
this.uuid = credentials.uuid
}
this.uuid = credentials.uuid
}

getBaseRepoURL() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ describe("API testing - BitBucket Cloud", () => {
type: "PASSWORD",
username: "foo",
password: "bar",
uuid: "",
}
)
let requestNo = 0
Expand Down Expand Up @@ -425,7 +424,6 @@ describe("API testing - BitBucket Cloud", () => {
type: "OAUTH",
oauthSecret: "superSecretOAUTH",
oauthKey: "superOAUTHKey",
uuid: "",
}
)
let requestNo = 0
Expand Down Expand Up @@ -464,7 +462,6 @@ describe("API testing - BitBucket Cloud", () => {
type: "OAUTH",
oauthSecret: "superSecretOAUTH",
oauthKey: "superOAUTHKey",
uuid: "",
}
)
let requestNo = 0
Expand Down Expand Up @@ -500,7 +497,6 @@ describe("API testing - BitBucket Cloud", () => {
type: "OAUTH",
oauthSecret: "superSecretOAUTH",
oauthKey: "superOAUTHKey",
uuid: "",
}
)

Expand Down

0 comments on commit f5ba1a6

Please sign in to comment.