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

Self review option for merge script #3650

Merged
Merged
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
9 changes: 5 additions & 4 deletions bin/ckan-merge-pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def latest_commit(self, repo: CkanRepo) -> Commit:
def merge_commit_message(self) -> str:
return f'Merge #{self.pull_request.number} {self.pull_request.title}'

def merge_into(self, repo: CkanRepo) -> bool:
if not self.approvers():
def merge_into(self, repo: CkanRepo, self_review: bool) -> bool:
if not self_review and not self.approvers():
print(f'PR #{self.pull_request.number} is not approved!')
return False
if not repo.on_master():
Expand Down Expand Up @@ -111,12 +111,13 @@ def merge_into(self, repo: CkanRepo) -> bool:
@option('--repo-path', type=click.Path(exists=True, file_okay=False),
default='.', help='Path to CKAN working copy')
@option('--token', required=False, envvar='GITHUB_TOKEN')
@option('--self-review', is_flag=True, default=False)
@argument('pr_num', type=click.INT)
def merge_pr(repo_path: str, token: str, pr_num: int) -> None:
def merge_pr(repo_path: str, token: str, self_review: bool, pr_num: int) -> None:
ckr = CkanRepo(repo_path)
ckpr = CkanPullRequest(Github(token).get_repo('KSP-CKAN/CKAN').get_pull(pr_num))
sys.exit(ExitStatus.success
if ckpr.merge_into(ckr)
if ckpr.merge_into(ckr, self_review)
else ExitStatus.failure)

if __name__ == '__main__':
Expand Down