Skip to content

Commit

Permalink
Add merge command
Browse files Browse the repository at this point in the history
  • Loading branch information
alexef committed Dec 6, 2024
1 parent 44237a9 commit 56542b2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.0.8
- Add `merge` command

## 1.0.7
- Add `--exclude-missing` when running `auto-pr status`
- Allows you to remove the `Missing PRs` section from the output
Expand Down
23 changes: 23 additions & 0 deletions autopr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,29 @@ def reopen():
_set_all_pull_requests_state(github.PullRequestState.OPEN)
click.secho("Finished reopening all closed unmerged pull requests")

@cli.command()
def merge():
"""Merge all mergeable pull requests"""
cfg = workdir.read_config(WORKDIR)
db = workdir.read_database(WORKDIR)
gh = github.create_github_client(cfg.credentials.api_key)

for repository in db.repositories:
if repository.existing_pr is not None:
details = github.get_pull_request(gh, repository)
if details.state == github.PullRequestState.OPEN.value:
if details.mergeable:
try:
github.merge_pull_request(gh, repository)
click.secho(f"Merged {repository.name}")
except ValueError as e:
click.secho(f"{e}")
else:
click.secho(f"Pull request {repository.name} is not mergeable")
else:
click.secho(f"Pull request {repository.name} is not open")



if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "auto-pr"
version = "1.0.7"
version = "1.0.8"
description = "Perform bulk updates across repositories"
license = "Apache-2.0"

Expand Down

0 comments on commit 56542b2

Please sign in to comment.