Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support labeling based on the pull request/commit title and messages #55

Open
XVilka opened this issue Mar 11, 2020 · 11 comments · May be fixed by #109
Open

Support labeling based on the pull request/commit title and messages #55

XVilka opened this issue Mar 11, 2020 · 11 comments · May be fixed by #109
Labels
feature request New feature or request to improve the current logic needs eyes

Comments

@XVilka
Copy link

XVilka commented Mar 11, 2020

To apply the label based on the pattern match in one of the fields in:

  • PR title
  • PR body
  • PR commit title
  • PR commit body
@austince
Copy link

austince commented Jan 13, 2021

The commit-specific matching might be more work, as it would require fetching all the commits that are contained in the PR, but the PR title and body should be already available.

What about adding a label config object item like pr: { body?: StringOrMatchConfig[], title?: StringOrMatchConfig[] }?

Ex:

# Add 'test' label to any change to *.spec.js files within the source dir
# or with a PR title that is in the form 'test:*'
# or with a PR body that contains the word 'test' but not 'bug'
test:
 - src/**/*.spec.js
 - pr:
     title:
       - 'test:*'
     body:
       - any: [ '*test*' ]
         all: [ '*bug*' ]

This could then be expanded to include the commits:

# Add 'test' label to any change to *.spec.js files within the source dir
# or with a PR title that is in the form 'test:*'
# or with a PR body that contains the word 'test' but not 'bug'
# or has any commits with a title in the form 'test:*'
test:
 - src/**/*.spec.js
 - pr:
     title:
       - 'test:*'
     body:
       - any: [ '*test*' ]
         all: [ '*bug*' ]
- commits:
    title:
      - 'test:*'

In typescript, this could then be modeled like:

export interface MatchConfig {
  all?: string[];
  any?: string[];
}

export type MatchConfigEntry = string | MatchConfig;

export interface PRConfigEntry {
  title?: MatchConfigEntry[];
  body?: MatchConfigEntry[];
}

export type ConfigEntry = MatchConfigEntry | { pr: PRConfigEntry };

export interface Config {
  [label: string]: ConfigEntry[];
}

const config: Config = {
  // ...
  test: [
    'src/**/*.spec.js',
    {
      pr: {
        title: ['test:*'],
        body: [
          {
            any: ['*test*'],
            all: ['*bug*']
          }
        ]
      }
    }
  ]
  // ...
}

@shadow81627 shadow81627 linked a pull request Jun 30, 2021 that will close this issue
@ssbarnea
Copy link

ssbarnea commented Oct 7, 2021

Release Drafter already has the auto-labeling feature, see https://github.com/release-drafter/release-drafter#autolabeler

Sadly, AFAIK, it does not have the ability to be used as a check that prevent a change from being merged if is missing the right labels.

@MaksimZhukov MaksimZhukov added the feature request New feature or request to improve the current logic label Dec 12, 2022
@felipefrancisco
Copy link

+1

2 similar comments
@marekpeszt
Copy link

+1

@merklefruit
Copy link

+1

@silasdavis
Copy link

silasdavis commented Jul 3, 2023

Can we also have the ability to specifically label based on git commit footers, e.g.

chore(foo): my fix

Risk: D
Urgency: 2

Signed-off-by: Silas Davis <[email protected]>

This would play nicely with conventional commits (https://www.conventionalcommits.org/en/v1.0.0/#specification), for example.

@MaksimZhukov MaksimZhukov linked a pull request Jul 12, 2023 that will close this issue
@phun-ky
Copy link

phun-ky commented Aug 14, 2023

Could this feature be expanded to let the labeler read the commit message, so for example, if a repo is following commitizen, we can tag PRs (and eventually issues), with the type of commit?

for example:

test: 💍 Remove test for untestable code, due to environment

would then add a test label

@kalvarez2
Copy link

Hi, would it be acceptable to instead of the structured way, "simply" to add an optional prefix on the blob?

For example:

label1:
- "body:#potato"

Would add the label "label1" if the body contains the string #potato

Looking at the code, this would be simpler to add, and from the user experience point of view I think it works ok to?

@Jaskowicz1
Copy link

I like that, would be extremely useful!

@kalvarez2
Copy link

@MaksimZhukov should I make another for 5.0 branch? is there any hope that this will be merged to 4.0?
#688

@sschuberth
Copy link

Release Drafter already has the auto-labeling feature, see https://github.com/release-drafter/release-drafter#autolabeler

No more lightweight / fitting comparison might be to https://github.com/fuxingloh/multi-labeler#features, tough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request to improve the current logic needs eyes
Projects
None yet
Development

Successfully merging a pull request may close this issue.