GithubHelp home page GithubHelp logo

ouzi-dev / needs-retitle Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 435 KB

needs-retitle is an external plugin for Prow

License: Apache License 2.0

Makefile 11.93% Go 86.63% Dockerfile 1.44%
kubernetes prow prow-components prow-plugin needs-retitle

needs-retitle's Introduction

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:

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

    external_plugins:
      org-foo/repo-bar:
      - name: needs-retitle
        # No endpoint specified implies "http://{{name}}".
        events:
        - pull_request
        # 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`
        # is in use, these two tokens are only needed if the PR or its mergeability changed.
        - 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:

    tide:
      sync_period: 1m
      merge_method:
        my-org: squash
      pr_status_base_urls:
        "*": https://prow.my-host.com/pr
      blocker_label: tide/merge-blocker
      squash_label: tide/merge-method-squash
      rebase_label: tide/merge-method-rebase
      merge_label: tide/merge-method-merge
      context_options:
        from-branch-protection: true
        skip-unknown-contexts: false
      queries:
        - orgs:
            - my-org
          labels:
            - lgtm
            - approved
          missingLabels:
            - do-not-merge
            - do-not-merge/hold
            - do-not-merge/work-in-progress
            - needs-rebase
            - do-not-merge/invalid-owners-file
            - 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

needs-retitle's People

Contributors

belitre avatar givanov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.