Skip to content

Commit

Permalink
Merge pull request #1849 from intuit/slack-validation-bug
Browse files Browse the repository at this point in the history
handle capital X in semver bump list
  • Loading branch information
hipstersmoothie committed Mar 3, 2021
2 parents 47462c0 + 1bb0ba8 commit ba1865e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions plugins/pr-body-labels/__tests__/pr-body-labels.test.ts
Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion plugins/pr-body-labels/src/index.ts
Expand Up @@ -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);
Expand Down

0 comments on commit ba1865e

Please sign in to comment.