Skip to content

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

Open
@XVilka

Description

@XVilka

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

Activity

austince

austince commented on Jan 13, 2021

@austince

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*']
          }
        ]
      }
    }
  ]
  // ...
}
linked a pull request that will close this issue on Jun 30, 2021
ssbarnea

ssbarnea commented on Oct 7, 2021

@ssbarnea

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.

felipefrancisco

felipefrancisco commented on May 10, 2023

@felipefrancisco

+1

marekpeszt

marekpeszt commented on May 18, 2023

@marekpeszt

+1

merklefruit

merklefruit commented on May 26, 2023

@merklefruit

+1

silasdavis

silasdavis commented on Jul 3, 2023

@silasdavis

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 <silas@example.com>

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

linked a pull request that will close this issueenable to add label by title #109on Jul 12, 2023

10 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or request to improve the current logicneeds eyes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @silasdavis@ssbarnea@XVilka@sschuberth@mofosyne

      Issue actions

        Support labeling based on the pull request/commit title and messages · Issue #55 · actions/labeler