Skip to content

Support for dynamic labels based on branches #8

@TheCleric

Description

@TheCleric

My team has a need for dynamic labels based on the branch names in the PR.

Specifically, if we are merging into a branch marked release/XXX (such as release/1.0) then we apply the tag XXX (so release/1.0 would get the tag 1.0).

To facilitate this I have added a feature to my fork of this library that is completely backwards compatible, but allows specifying regular expressions with groups, and labels based off those groups.

For example in my use case above, you could create a config like so:

$1:
  baseRegExp: 'release[/](.*)'

This would then attempt to match the base branch of a PR with the above regular expression. If it matches it would apply the first matched group ($1) as the label. So release/1.0 would return 1.0 as the label as needed above.

Here's the release version with the change in it (including unit tests).

https://github.com/TheCleric/pr-branch-labeler/tree/v3.1

If you feel like this would be of benefit to merge into your library, please let me know and I'll create a PR. I also recognize that this may be a little too specific or complex for the goal of this library. Either way is fine with me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions