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

Support creating draft PRs for Github Pull Requests #351

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
2 changes: 2 additions & 0 deletions all_repos/push/github_pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions tests/push/github_pull_request_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
')'
)
1 change: 1 addition & 0 deletions tests/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
')'
)

Expand Down
Loading