srvaroa/labeler

Multiple matchers on a label takes the results of the last matcher

Closed this issue · 3 comments

We just ran into an issue where if you have multiple matchers (in our case title and file paths) then the results of the last matcher are used. So in our case the title matcher returned true and the file path matcher returned false and the label was not applied.

Thanks for reporting!

I think there is indeed a bug in the condition evaluations that will indeed take only the result of the latest condition, I'll review it later and try to get it fixed.

That said I'm not sure fixing this will give you the result you expect. I understand from your report that you'd actually want an OR (e.g. apply the label if either the title or files match). Is that right?

The current (buggy) implementation tries to AND all conditions, so this:

  WIP:
    title: "^WIP:.*"
    files:
      - "cmd/.*_tests.go"

Would only apply the label if both conditions match.

It's possible to implement the OR behaviour with minor changes. If you're interested in that I can get both changes in.

Stoom commented

Yeah, Ideally it would apply if any of the conditions are met. I guess a workaround for this could be listing the label twice.

Hi @Stoom this PR should fix both the bug, and allow implementing the OR with multiple matchers (it requires an update in config format but it should be fairly straight forward).

I've added a few tests for this so I'm fairly confident this will work, but if you can give it a go using that branch (with this in your github workflows yaml):

 - uses: srvaroa/labeler@g.dev

That'd be very appreciated.