Skip to content
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 = """
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should perhaps just include this in the main message

the reason being that until recently i didnt discover how to create a draft pr - so habitually created a non-draft and then marked it so

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm - altho i guess this also sends a message to non-new-contributors - which is kinda confusing given the name of this module

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, if someone has contributed a few times and then does a draft I think they should get the warning. I don't think there is a hook for "has ever done a draft before" so it's all or nothing.
moved the module for clarity

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)