Skip to content

Commit

Permalink
Merge pull request #1033 from valscion/circle-ci-commit-hash
Browse files Browse the repository at this point in the history
Take commit hash from CircleCI
  • Loading branch information
orta committed Apr 16, 2020
2 parents f58ee85 + bf3e021 commit 8090b86
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ x

<!-- Your comment below this -->

- Take commit hash from CircleCI environment variable [@valscion]
- Fix project path with /- in GitLab MR URL [@pgoudreau]
- When creating a new PR with `createOrUpdatePR`, add the description (as done when editing) - [@sogame]
<!-- Your comment above this -->
Expand Down
4 changes: 4 additions & 0 deletions source/ci_source/providers/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ export class Circle implements CISource {
get ciRunURL() {
return this.env["CIRCLE_BUILD_URL"]
}

get commitHash(): string {
return this.env.CIRCLE_SHA1
}
}
16 changes: 16 additions & 0 deletions source/ci_source/providers/_tests/_circle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,19 @@ describe(".repoSlug", () => {
expect(circle.repoSlug).toEqual("artsy/eigen")
})
})

describe("commit hash", () => {
it("returns correct commit hash when present", () => {
const env = {
...correctEnv,
CIRCLE_SHA1: "1234abc",
}
const circle = new Circle(env)
expect(circle.commitHash).toEqual("1234abc")
})

it("returns no commit hash when not present", () => {
const circle = new Circle(correctEnv)
expect(circle.commitHash).toBeUndefined()
})
})

0 comments on commit 8090b86

Please sign in to comment.