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

repokitteh: adding warning about draft PRS #17063

Merged
merged 4 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ versioning guidelines:

Please see [support/README.md](support/README.md) for more information on these hooks.

* Create your PR. If your PR adds new code, it should include tests [covering](source/docs/coverage.md) the new code.
* Create your PR. If your PR adds new code, it should include tests [covering](source/docs/coverage.md) the new code. Please note that draft PRs may not be reviewed and will likely not be triaged, so do not create your PR as a draft if you want prompt reviews!
* Tests will automatically run for you.
* We will **not** merge any PR that is not passing tests.
* PRs are expected to have 100% test coverage for added code. This can be verified with a coverage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,52 @@ In the meantime, please take a look at the [contribution guidelines](https://git

"""

DRAFT_MESSAGE = """
As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!
"""


def get_pr_author_association(issue_number):
return github.call(
method="GET",
path="repos/envoyproxy/envoy/pulls/%s" % issue_number)["json"]["author_association"]

def get_pr_is_draft(issue_number):
return github.call(
method="GET",
path="repos/envoyproxy/envoy/pulls/%s" % issue_number)["json"]["draft"]

def is_newcontributor(issue_number):
return (
get_pr_author_association(issue_number)
in ["NONE", "FIRST_TIME_CONTRIBUTOR", "FIRST_TIMER"])

def is_draft(issue_number):
return (get_pr_is_draft(issue_number) is True)

def should_message_newcontributor(action, issue_number):
return (
action == 'opened'
and is_newcontributor(issue_number))

def warn_about_drafts(action, issue_number):
return (
action == 'opened'
and is_draft(issue_number))

def send_newcontributor_message(sender):
github.issue_create_comment(NEW_CONTRIBUTOR_MESSAGE % sender)

def send_draft_wip_notice(sender):
github.issue_create_comment(DRAFT_MESSAGE)

def _pr(action, issue_number, sender, config):
if should_message_newcontributor(action, issue_number):
send_newcontributor_message(sender)
if warn_about_drafts(action, issue_number):
send_draft_wip_notice()

handlers.pull_request(func=_pr)