Repository: asottile/all-repos

Issue:
Support creating draft PRs for AzDO
Hey, I successfully configured the tool to run with Azure DevOps, but I noticed that config included in the repo always causes creating standard PRs. In my organization, a standard PR automatically triggers CI, so it creates high queues for CI agents when a lot of PRs are created.

For me, the simplest solution was to create draft PRs instead. AzDO supports `isDraft` parameter in the API call ([docs](https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-requests/create?view=azure-devops-rest-6.0)), so I did a minimal change in #322, and it seems to be working fine after adding `"draft": true` in `"push_settings"` in all-repos JSON config.

I thought that it might be useful for somebody out there, hence this issue and PR. Shall we merge it?

Discussion:

Patch:
diff --git a/all_repos/push/azure_repos_pull_request.py b/all_repos/push/azure_repos_pull_request.py
index 4d1e075..58d71e8 100644
--- a/all_repos/push/azure_repos_pull_request.py
+++ b/all_repos/push/azure_repos_pull_request.py
@@ -19,6 +19,7 @@ class Settings(NamedTuple):
     base_url: str = 'https://dev.azure.com'
     api_key: str | None = None
     api_key_env: str | None = None
+    draft: bool = False
 
     def __repr__(self) -> str:
         return hide_api_key_repr(self)
@@ -53,6 +54,7 @@ def make_pull_request(
         'description': body.decode().strip(),
         'sourceRefName': f'refs/heads/{head}',
         'targetRefName': f'refs/heads/{autofix_lib.target_branch()}',
+        'isDraft': settings.draft,
     }).encode()
 
     pull_request_url = (


Test patch:
diff --git a/tests/push/azure_repos_pull_request_test.py b/tests/push/azure_repos_pull_request_test.py
index c36c400..b993a97 100644
--- a/tests/push/azure_repos_pull_request_test.py
+++ b/tests/push/azure_repos_pull_request_test.py
@@ -82,5 +82,6 @@ def test_settings_repr():
         "    base_url='https://dev.azure.com',\n"
         '    api_key=...,\n'
         '    api_key_env=None,\n'
+        '    draft=False,\n'
         ')'
     )