Allow setting reviewers when using github_pull_request
See original GitHub issueI would like to be able to set the reviewers for PRs created through all-repos.
all-repos-sed ... --reviewers mycolleague
I was going to implement this as a custom push module, but currently push modules can only receive Settings
and branch_name
.
One approach would be to implement push strategies as classes with a hook for adding additional parser arguments. Something like:
class GitHubPullRequest(BasePushStrategy):
def add_arguments(self, parser: ParserType):
parser.add_arguments("--reviewers", nargs="*")
# or "def handle", to match Django's management commands
def __call__(self, settings: Settings, branch_name: str, parsed_args: Any) -> None:
# ...
resp = github_api.req(
f"{settings.base_url}/repos/{repo_slug}/pulls",
data=data,
headers=headers,
method="POST",
)
url = resp.json["url"]
html_url = resp.json["html_url"]
print(f"Pull request created at {html_url}")
reviewers = parsed_args.reviewers
if reviewers:
resp = github_api.req(
f"{url}/requested_reviewers",
data=json.dumps({"reviewers": reviewers}).encode(),
headers=headers,
method="POST",
)
print(f"Requested review from {reviewers}")
The "push"
config in all-repos.json
would point to these classes instead of modules.
{
"push": "all_repos.push.GitHubPullRequest"
}
Open questions:
- Is the above interface a good idea? 1a. If so, is it OK to implement it as a breaking change?
- Should the “reviewer” functionality be included in all-repos core?
I don’t have a strong feeling on 2. As long as there’s a way to do it, I’m fine keeping it as custom code outside of core to start. Up to you, @asottile
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Managing code review settings for your team - GitHub Docs
In this article Team maintainers and organization owners can configure code review settings. Code review settings are available in all public repositories ...
Read more >Requesting a pull request review - GitHub Docs
Requesting a pull request review · Under your repository name, click Pull requests. · In the list of pull requests, click the pull...
Read more >About pull request reviews - GitHub Docs
Reviews allow collaborators to comment on the changes proposed in pull requests, approve the changes, or request further changes before the pull request...
Read more >Managing pull request reviews in your organization
In the top right corner of GitHub.com, click your profile photo, then click Your organizations. · Next to the organization, click Settings. ·...
Read more >Approving a pull request with required reviews - GitHub Docs
Under your repository name, click Pull requests. · In the list of pull requests, click the pull request you'd like to review. ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fair enough–I can see how allowing plugins to define their own arguments could open Pandora’s Box.
Sure, this seems workable. With https://github.com/asottile/all-repos/pull/132 , I’d be able to do something like
thanks!