Skip to content

Commit

Permalink
[slack] Specify head ref as getCommit option if event trigger is pull…
Browse files Browse the repository at this point in the history
…_req
  • Loading branch information
homoluctus committed Nov 21, 2019
1 parent 57775e9 commit 5171a6d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11016,8 +11016,9 @@ class Block {
getCommitFields(token) {
return __awaiter(this, void 0, void 0, function* () {
const { owner, repo } = this.context.repo;
const head_ref = process.env.GITHUB_HEAD_REF;
const ref = this.isPullRequest
? this.context.ref.replace(/refs\/heads\//, '')
? head_ref.replace(/refs\/heads\//, '')
: this.context.sha;
const client = new github.GitHub(token);
const { data: commit } = yield client.repos.getCommit({ owner, repo, ref });
Expand Down
3 changes: 2 additions & 1 deletion src/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ class Block {
*/
public async getCommitFields(token: string): Promise<MrkdwnElement[]> {
const {owner, repo} = this.context.repo;
const head_ref: string = process.env.GITHUB_HEAD_REF as string;
const ref: string = this.isPullRequest
? this.context.ref.replace(/refs\/heads\//, '')
? head_ref.replace(/refs\/heads\//, '')
: this.context.sha;
const client: github.GitHub = new github.GitHub(token);
const {
Expand Down

0 comments on commit 5171a6d

Please sign in to comment.