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

add repoproc for allow_auto_merge #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions ghconf/plumbing/repositories/common_procs.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,34 @@ def _set_delete_branch_on_merge(change: Change[str]) -> Change[str]:
return delete_branch_on_merge


def set_allow_auto_merge(value: bool) -> repoproc_t:
def allow_auto_merge(org: Organization, repo: Repository, branches: Dict[str, Branch]) -> List[Change[str]]:
"""
Turns on a feature that allows automatic merging of PRs
"""
def _set_allow_auto_merge(change: Change[str]) -> Change[str]:
print_debug("[%s] Enabling auto merge" % highlight(repo.name))
try:
repo.edit(allow_auto_merge=value)
except GithubException:
return change.failure()

return change.success()

if repo.allow_auto_merge != value:
change = Change(
meta=ChangeMetadata(
executor=_set_allow_auto_merge,
),
action=ChangeActions.REPLACE,
before="Auto merge: %s" % "Enabled" if repo.allow_auto_merge else "Disabled",
after="Auto merge: %s" % "Enabled" if value else "Disabled"
)
return [change]
return []
return allow_auto_merge


GOT = TypeVar("GOT")
_GithubOptional = Union[GOT, _NotSetType]

Expand Down