From 1bb0ba8117fc016ed0e9088c0c150d69b43d3e36 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Wed, 3 Mar 2021 12:13:36 -0800 Subject: [PATCH] handle capital X in semver bump list --- .../__tests__/pr-body-labels.test.ts | 17 +++++++++++++++++ plugins/pr-body-labels/src/index.ts | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/pr-body-labels/__tests__/pr-body-labels.test.ts b/plugins/pr-body-labels/__tests__/pr-body-labels.test.ts index 19912eaee..f9d3088e6 100644 --- a/plugins/pr-body-labels/__tests__/pr-body-labels.test.ts +++ b/plugins/pr-body-labels/__tests__/pr-body-labels.test.ts @@ -37,6 +37,23 @@ describe("Pr-Body-Labels Plugin", () => { expect(addLabelToPr).toHaveBeenCalledWith(1, "patch"); }); + test("add labels present in project capital X", async () => { + const plugin = new PrBodyLabels(); + const hooks = makeHooks(); + const addLabelToPr = jest.fn(); + + plugin.apply({ + hooks, + labels: [{ name: "patch" }], + git: { addLabelToPr }, + } as any); + + await hooks.prCheck.promise({ + pr: { body: "- [X] `patch`", number: 1 }, + } as any); + expect(addLabelToPr).toHaveBeenCalledWith(1, "patch"); + }); + test("not add labels in disabledLabels list", async () => { const plugin = new PrBodyLabels({ disabledLabels: ["patch"] }); const hooks = makeHooks(); diff --git a/plugins/pr-body-labels/src/index.ts b/plugins/pr-body-labels/src/index.ts index 47b59576a..d2bab558a 100644 --- a/plugins/pr-body-labels/src/index.ts +++ b/plugins/pr-body-labels/src/index.ts @@ -32,8 +32,12 @@ export default class PrBodyLabelsPlugin implements IPlugin { await Promise.all( auto.labels.map(async (label) => { + const hasCheckedLabel = + pr.body?.includes(`- [x] \`${label.name}\``) || + pr.body?.includes(`- [X] \`${label.name}\``); + if ( - pr.body?.includes(`- [x] \`${label.name}\``) && + hasCheckedLabel && !this.options.disabledLabels.includes(label.name) ) { await auto.git?.addLabelToPr(pr.number, label.name);