From 8d66c039af3812a9d54cb970473d3c426b13a4b0 Mon Sep 17 00:00:00 2001 From: nsmith269 Date: Thu, 7 Nov 2024 09:40:14 -0500 Subject: [PATCH 1/2] Support creating draft PRs for Github Pull Requests --- all_repos/push/github_pull_request.py | 2 ++ tests/push/github_pull_request_test.py | 2 ++ tests/util_test.py | 1 + 3 files changed, 5 insertions(+) diff --git a/all_repos/push/github_pull_request.py b/all_repos/push/github_pull_request.py index 68bb92e..a3db1b1 100644 --- a/all_repos/push/github_pull_request.py +++ b/all_repos/push/github_pull_request.py @@ -17,6 +17,7 @@ class Settings(NamedTuple): base_url: str = 'https://api.github.com' api_key: str | None = None api_key_env: str | None = None + draft: bool = False # TODO: https://github.com/python/mypy/issues/8543 def __repr__(self) -> str: @@ -56,6 +57,7 @@ def make_pull_request( 'body': body.decode().strip(), 'base': autofix_lib.target_branch(), 'head': head, + 'draft': settings.draft, }).encode() return github_api.req( diff --git a/tests/push/github_pull_request_test.py b/tests/push/github_pull_request_test.py index 08c6a68..bc5e211 100644 --- a/tests/push/github_pull_request_test.py +++ b/tests/push/github_pull_request_test.py @@ -50,6 +50,7 @@ def test_github_pull_request(mock_urlopen, fake_github_repo): assert data['title'] == 'This is a commit message' assert data['body'] == 'Here is some more information!' assert data['head'] == 'feature' + assert data['draft'] is False @pytest.fixture @@ -96,5 +97,6 @@ def test_settings_repr(): " base_url='https://api.github.com',\n" ' api_key=...,\n' ' api_key_env=None,\n' + ' draft=False,\n' ')' ) diff --git a/tests/util_test.py b/tests/util_test.py index 3b1f8c0..ede485b 100644 --- a/tests/util_test.py +++ b/tests/util_test.py @@ -31,6 +31,7 @@ def test_hide_api_key_repr(): " base_url='https://api.github.com',\n" ' api_key=...,\n' ' api_key_env=None,\n' + ' draft=False,\n' ')' ) From b65ca038fd303a125c999f8e6f56b89a4ed7f9df Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Wed, 13 Nov 2024 14:19:46 -0500 Subject: [PATCH 2/2] update documentation Add option to the README update docs --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fc04bf7..f855f14 100644 --- a/README.md +++ b/README.md @@ -477,11 +477,12 @@ branch. #### Optional `push_settings` +- `base_url` (default: `https://api.github.com`) is the base URL to the Github + API to use (for Github Enterprise support set this to `https://{your_domain}/api/v3`). +- `draft` (default: `false`) if true will open the pull request as a draft. - `fork` (default: `false`): (if applicable) a fork will be created and pushed to instead of the upstream repository. The pull request will then be made to the upstream repository. -- `base_url` (default: `https://api.github.com`) is the base URL to the Github - API to use (for Github Enterprise support set this to `https://{your_domain}/api/v3`). ### `all_repos.push.bitbucket_server_pull_request`