Skip to content

Commit

Permalink
Merge pull request #12 from fossapps/add_branch
Browse files Browse the repository at this point in the history
Add branch
  • Loading branch information
cyberhck authored Sep 25, 2019
2 parents ebc4466 + 6a11a30 commit 57a7723
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/PayloadHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Webhooks.WebhookPayloadPullRequest> = {
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",
Expand Down Expand Up @@ -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
};
Expand Down
4 changes: 3 additions & 1 deletion src/PayloadHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ITemplateVars {
diff_url: string;
patch_url: string;
issue_url: string;
branch: string;
};
labels: WebhookPayloadIssuesIssueLabelsItem[];
}
Expand Down Expand Up @@ -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
}
};
}
Expand Down

0 comments on commit 57a7723

Please sign in to comment.