From cb5f4480b27463774f930d1a0708580fa778272c Mon Sep 17 00:00:00 2001 From: Amiel Martin Date: Wed, 15 Sep 2021 09:23:41 -0800 Subject: [PATCH] Use correct branch name and update tests --- __tests__/main.test.ts | 4 ++-- src/labeler.ts | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 1c89ea8f..5a0990ef 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -105,7 +105,7 @@ describe("run", () => { }); it("adds labels based on the branch names that match the glob pattern", async () => { - github.context.ref = "test/testing-time"; + github.context.payload.pull_request!.head = {ref: "test/testing-time"}; usingLabelerConfigYaml("branches.yml"); await run(); @@ -119,7 +119,7 @@ describe("run", () => { }); it("adds labels based on branch names that match different glob patterns", async () => { - github.context.ref = "my/feature/that-i-like"; + github.context.payload.pull_request!.head = {ref: "my/feature/that-i-like"}; usingLabelerConfigYaml("branches.yml"); await run(); diff --git a/src/labeler.ts b/src/labeler.ts index a6cf5eaa..93eeef7a 100644 --- a/src/labeler.ts +++ b/src/labeler.ts @@ -216,10 +216,8 @@ function checkAll(changedFiles: string[], globs: string[]): boolean { function checkBranch(glob: string): boolean { const matcher = new Minimatch(glob); - const branchName = github.context.ref; - const branchName2 = github.context.payload.pull_request!.head.ref; + const branchName = github.context.payload.pull_request!.head.ref; core.debug(` checking "branch" pattern against ${branchName}`); - core.debug(` - but we should be checking ${branchName2}`); core.debug(` - ${printPattern(matcher)}`); if (!matcher.match(branchName)) { core.debug(` ${printPattern(matcher)} did not match`);