pr-labeler-action icon indicating copy to clipboard operation
pr-labeler-action copied to clipboard

Label filters based on Head & Base branch names

Open deepakputhraya opened this issue 5 years ago • 11 comments

Are there any plans to add labels based on regex matching head/base branch?

Current config -

feature: ['feature/*', 'feat/*']
fix: fix/*
chore: chore/*
fixed-branch: fixed-branch-name

Suggested config

feature:
  head: ["feature/*", "feat/*"]
hotfix:
  base: master
  ignore: ["develop"]
release:
  head: develop
  base: master

This could give more control over labelling.

deepakputhraya avatar Nov 06 '19 10:11 deepakputhraya

Hello @deepakputhraya, I appreciate your idea. Could you be so kind and specify what you mean with the ignore: ["develop"] configuration? We should also discuss if the specified conditions would be combined in an "AND" or "OR" statement. I would prefer the "AND" matching like when given base matches and when given head matches the specified regex then add the label.

amacado avatar Nov 06 '19 12:11 amacado

We should also discuss if the specified conditions would be combined in an "AND" or "OR" statement. I would prefer the "AND" matching like when given base matches and when given head matches the specified regex then add the label.

Apologies not being explicit. I just assumed the AND case with head & base fields.

Could you be so kind and specify what you mean with the ignore: ["develop"] configuration?

I would like to make a small correction

hotfix:
  base: master
  ignore_head: ["develop"] # changed from ignore to ignore_head

Ignore branches with specific names for this rule. This is probably possible to support with regex but the thought here was to make the rule more readable.

Do you think adding filter like PR size to this make sense? I understand that there are Github actions for this specific scenario, but providing PR size filter with base & head would make it more customizable. Example:

hotfix:
  base: master
  head: "hotfix/*"
  max_line_changes: 10 

Assuming that it is AND across properties and OR within a property.

deepakputhraya avatar Nov 07 '19 05:11 deepakputhraya

To be honest, in my opinion the ignore_head and max_line_changes options make this small and useful action pretty complicated. Specially the ignore_head option.

I agree that an optional base & master definition improves the customisation possibilities of this action, but I like to keep things simple. For compatibility reasons I suggest to keep this configuration valid:

hotfix: ["hotfix/*"]

same as

hotfix:
  head: ["hotfix/*"]

What is your opinion @TimonVS ?

amacado avatar Nov 07 '19 08:11 amacado

As long as we have sane default values or ignore fields that are not set it would still remain simple. Options such as max_line_changes & ignore_head would be used who require more control or have more specific needs. For an average user of the action, they would probably stick to the options that you mentioned.

deepakputhraya avatar Nov 07 '19 13:11 deepakputhraya

@TimonVS @amacado Any update on this guys?

deepakputhraya avatar Nov 11 '19 13:11 deepakputhraya

@deepakputhraya feel free to fork and do a pull request :)

amacado avatar Nov 11 '19 13:11 amacado

Hey @deepakputhraya! Those are some good suggestions. I feel like we can add base and head options pretty easily. I think that ignore_head can be implemented by prefixing the head value with a !, this is supported by matcher.

I'm not entirely convinced that we should add the max_line_changes option currently. The consequence of adding this option is that the Action has to run for every push to a PR because the total lines changed can change every commit and if it goes below the threshold in a later, should we remove the label again?

Would you have time to work on this feature?

TimonVS avatar Nov 12 '19 12:11 TimonVS

@TimonVS @amacado I would love to. I can probably get to this in a few weeks if nobody has picked this up by then.

deepakputhraya avatar Nov 22 '19 07:11 deepakputhraya

I would really be interested by a way to automatically add a label based on the target branch.

For instance, I'd like to add automatically an hotfix label on every branch which target stable.

Did you tried somethihng @deepakputhraya ?

VincentLanglet avatar Jun 03 '22 10:06 VincentLanglet

Hello, I created a PR for it ➡️ https://github.com/TimonVS/pr-labeler-action/pull/61

It only adds the head and base options since there seemed to be a consensus around them, and uses the AND operator when both options are used in combination.

gdostie avatar Aug 15 '22 20:08 gdostie

@TimonVS

Any chance to get the above PR reviewed/released? It would definitely help us!

GermainBergeron avatar Sep 12 '22 12:09 GermainBergeron