labeler: add --authed-dry-run flag

Some data such as author_association is only available to authenticated API
users. This helps with testing.
This commit is contained in:
Maxwell G
2023-07-25 16:24:40 +00:00
parent 5c2125dffa
commit dd27494b8f

View File

@@ -161,8 +161,14 @@ def cb():
@APP.command(name="pr")
def process_pr(pr_number: int, dry_run: bool = False) -> None:
gclient, repo = get_repo(authed=not dry_run)
def process_pr(
pr_number: int, dry_run: bool = False, authed_dry_run: bool = False
) -> None:
authed = not dry_run
if authed_dry_run:
dry_run = True
authed = True
gclient, repo = get_repo(authed=authed)
pr = repo.get_pull(pr_number)
ctx = PRLabelerCtx(client=gclient, repo=repo, pr=pr, dry_run=dry_run)
if pr.state != "open":
@@ -175,8 +181,14 @@ def process_pr(pr_number: int, dry_run: bool = False) -> None:
@APP.command(name="issue")
def process_issue(issue_number: int, dry_run: bool = False) -> None:
gclient, repo = get_repo(authed=not dry_run)
def process_issue(
issue_number: int, dry_run: bool = False, authed_dry_run: bool = False
) -> None:
authed = not dry_run
if authed_dry_run:
dry_run = True
authed = True
gclient, repo = get_repo(authed=authed)
issue = repo.get_issue(issue_number)
ctx = IssueLabelerCtx(client=gclient, repo=repo, issue=issue, dry_run=dry_run)
if issue.state != "open":