diff --git a/src/PayloadHelper.test.ts b/src/PayloadHelper.test.ts index 903dd53..284aa3a 100644 --- a/src/PayloadHelper.test.ts +++ b/src/PayloadHelper.test.ts @@ -64,11 +64,25 @@ describe("PayloadHelper", () => { expect(helper.getTemplateVariables()).toStrictEqual(expectedData); }); it("should be able to return pull request variables", () => { + // @ts-ignore const context: Context = { payload: { // @ts-ignore pull_request: { body: "pr_body", + head: { + ref: "test-branch", + label: "", + sha: "", + // @ts-ignore + repo: { + id: 1, + node_id: "1", + name: "", + full_name: "", + private: false + } + }, number: 5, labels: [], patch_url: "https://github.com/fossapps/Handlebars-Issue-and-Pull-Requests/pull/1.patch", @@ -97,7 +111,8 @@ describe("PayloadHelper", () => { patch_url: "https://github.com/fossapps/Handlebars-Issue-and-Pull-Requests/pull/1.patch", issue_url: "https://github.com/fossapps/Handlebars-Issue-and-Pull-Requests/pull/1", html_url: "https://github.com/fossapps/Handlebars-Issue-and-Pull-Requests/pull/1", - diff_url: "https://github.com/fossapps/Handlebars-Issue-and-Pull-Requests/pull/1.diff" + diff_url: "https://github.com/fossapps/Handlebars-Issue-and-Pull-Requests/pull/1.diff", + branch: "test-branch" }, id: 5 }; diff --git a/src/PayloadHelper.ts b/src/PayloadHelper.ts index b5ebb8c..b6e201d 100644 --- a/src/PayloadHelper.ts +++ b/src/PayloadHelper.ts @@ -21,6 +21,7 @@ export interface ITemplateVars { diff_url: string; patch_url: string; issue_url: string; + branch: string; }; labels: WebhookPayloadIssuesIssueLabelsItem[]; } @@ -55,7 +56,8 @@ export class PayloadHelper implements IPayloadHelper { diff_url: prPayload.pull_request.diff_url, html_url: prPayload.pull_request.html_url, issue_url: prPayload.pull_request.issue_url, - patch_url: prPayload.pull_request.patch_url + patch_url: prPayload.pull_request.patch_url, + branch: prPayload.pull_request.head.ref } }; }