Skip to content

Commit

Permalink
Merge pull request #917 from mmiszy/fix-buddy-pr-int
Browse files Browse the repository at this point in the history
Fix Buddy.works isPR because PR ids are not always ints
  • Loading branch information
orta authored Sep 13, 2019
2 parents eeea80f + 2cce4c2 commit dd5da6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

<!-- Your comment below this -->

- Fix Buddy.works isPR and use PR number instead of PR ID - [@mmiszy]

<!-- Your comment above this -->

# 9.2.0
Expand Down
7 changes: 4 additions & 3 deletions source/ci_source/providers/BuddyWorks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ export class BuddyWorks implements CISource {
}

get isPR(): boolean {
const mustHave = ["BUDDY_PIPELINE_ID", "BUDDY_EXECUTION_PULL_REQUEST_ID", "BUDDY_REPO_SLUG"]
const mustBeInts = ["BUDDY_EXECUTION_PULL_REQUEST_ID"]
const mustHave = ["BUDDY_PIPELINE_ID", "BUDDY_EXECUTION_PULL_REQUEST_NO", "BUDDY_REPO_SLUG"]
const mustBeInts = ["BUDDY_EXECUTION_PULL_REQUEST_NO"]

return ensureEnvKeysExist(this.env, mustHave) && ensureEnvKeysAreInt(this.env, mustBeInts)
}

get pullRequestID(): string {
return this.env.BUDDY_EXECUTION_PULL_REQUEST_ID
return this.env.BUDDY_EXECUTION_PULL_REQUEST_NO
}

get repoSlug(): string {
Expand Down
6 changes: 3 additions & 3 deletions source/ci_source/providers/_tests/_buddyWorks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getCISourceForEnv } from "../../get_ci_source"

const correctEnv = {
BUDDY_PIPELINE_ID: "170873",
BUDDY_EXECUTION_PULL_REQUEST_ID: "1799",
BUDDY_EXECUTION_PULL_REQUEST_NO: "1799",
BUDDY_REPO_SLUG: "danger/dangerjs",
BUDDY_EXECUTION_URL:
"https://app.buddy.works/danger/dangerjs/pipelines/pipeline/170873/execution/5d6d49dbaab2cb6fdf975c71",
Expand Down Expand Up @@ -39,7 +39,7 @@ describe(".isPR", () => {
expect(buddyWorks.isPR).toBeFalsy()
})

const envs = ["BUDDY_EXECUTION_PULL_REQUEST_ID", "BUDDY_REPO_SLUG"]
const envs = ["BUDDY_EXECUTION_PULL_REQUEST_NO", "BUDDY_REPO_SLUG"]
envs.forEach((key: string) => {
const env = Object.assign({}, correctEnv)
env[key] = null
Expand All @@ -52,7 +52,7 @@ describe(".isPR", () => {

it("needs to have a PR number", () => {
const env = Object.assign({}, correctEnv)
delete env.BUDDY_EXECUTION_PULL_REQUEST_ID
delete env.BUDDY_EXECUTION_PULL_REQUEST_NO
const buddyWorks = new BuddyWorks(env)
expect(buddyWorks.isPR).toBeFalsy()
})
Expand Down

0 comments on commit dd5da6f

Please sign in to comment.