项目作者: ouzi-dev

项目描述 :
needs-retitle is an external plugin for Prow
高级语言: Go
项目地址: git://github.com/ouzi-dev/needs-retitle.git
创建时间: 2020-07-03T11:06:48Z
项目社区:https://github.com/ouzi-dev/needs-retitle

开源协议:Apache License 2.0

下载


needs-retitle

Overview

needs-retitle is an external plugin for prow to avoid merging PRs when the title doesn’t match a provided regular expression.

It is based on the needs-rebase plugin, so the code is more or less the same.

The plugin will check pull requests in the enabled repos and will add a tag needs-retitle to the pull requests whose titles don’t match the provided regular expression.

The plugin will run every time a pull request is created, edited or new commits are added. It will also run periodically checking open pull requests.

Configuration

You’ll need to add new things to your prow plugins.yaml file:

  • The plugin configuration: you need to provide a regular expression (required), and an optional error message. The message will be added as a comment when the plugin detects a pull request with a title that doesn’t match the regular expression. If no error message is provided the plugin will add a default message. Example:

    1. needs_retitle:
    2. regexp: "^(fix:|feat:|major:).*$"
    3. error_message: |
    4. Invalid title for the PR, the title needs to be like:
    5. fix: this is a fix commit
    6. feat: this is a feature commit
    7. major: this is a major commit
  • The settings to enable it as external plugin for prow, for example:

    1. external_plugins:
    2. org-foo/repo-bar:
    3. - name: needs-retitle
    4. # No endpoint specified implies "http://{{name}}".
    5. events:
    6. - pull_request
    7. # Dispatching issue_comment events to the needs-retitle plugin is optional. If enabled, this may cost up to two token per comment on a PR. If `ghproxy`
    8. # is in use, these two tokens are only needed if the PR or its mergeability changed.
    9. - issue_comment
  • Add the new label to missingLabels in the tide settings (in prow usually in config.yaml), that way the label needs-retitle will stop tide from merging the pull requests, example:

    1. tide:
    2. sync_period: 1m
    3. merge_method:
    4. my-org: squash
    5. pr_status_base_urls:
    6. "*": https://prow.my-host.com/pr
    7. blocker_label: tide/merge-blocker
    8. squash_label: tide/merge-method-squash
    9. rebase_label: tide/merge-method-rebase
    10. merge_label: tide/merge-method-merge
    11. context_options:
    12. from-branch-protection: true
    13. skip-unknown-contexts: false
    14. queries:
    15. - orgs:
    16. - my-org
    17. labels:
    18. - lgtm
    19. - approved
    20. missingLabels:
    21. - do-not-merge
    22. - do-not-merge/hold
    23. - do-not-merge/work-in-progress
    24. - needs-rebase
    25. - do-not-merge/invalid-owners-file
    26. - needs-retitle

Build

  • To make just the binary run: make build
  • To build an specific version run: VERSION=v0.1.0 make build
  • To run the tests run: make test
  • To build the docker image run: make docker-build

Deploy

You can find manifest to use as example to deploy the plugin in deploy

Remember to change the version, the manifests are using as version canary