Skip to content
This repository was archived by the owner on Nov 28, 2024. It is now read-only.

Commit ddda4b0

Browse files
authored
Merge pull request #79 from sileht/dry-run
Make dry-run going a bit further
2 parents c99a771 + 7cc1e78 commit ddda4b0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

git_pull_request/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ def fork_and_push_pull_request(g, hosttype, repo_to_fork, rebase,
514514
if dry_run:
515515
LOG.info("Would force-push branch `%s' to remote `%s/%s'",
516516
branch, remote_to_push, remote_branch)
517-
return
518517
else:
519518
LOG.info("Force-pushing branch `%s' to remote `%s/%s'",
520519
branch, remote_to_push, remote_branch)
@@ -528,6 +527,10 @@ def fork_and_push_pull_request(g, hosttype, repo_to_fork, rebase,
528527
head=head))
529528
if pulls:
530529
for pull in pulls:
530+
if dry_run:
531+
LOG.info("Pull-request would be updated:\n %s", pull.html_url)
532+
continue
533+
531534
LOG.info("Pull-request updated:\n %s", pull.html_url)
532535

533536
if force_editor:
@@ -543,12 +546,18 @@ def fork_and_push_pull_request(g, hosttype, repo_to_fork, rebase,
543546
elif message:
544547
pull.edit(body=message)
545548
LOG.debug("Updated pull-request message")
549+
if dry_run:
550+
return
546551
if comment:
547-
# FIXME(jd) we should be able to comment directly on a PR without
548-
# getting it as an issue but pygithub does not allow that yet
552+
# FIXME(jd) we should be able to comment directly on a PR
553+
# without getting it as an issue but pygithub does not allow
554+
# that yet
549555
repo_to_fork.get_issue(pull.number).create_comment(comment)
550556
LOG.debug("Commented: \"%s\"", comment)
551557
else:
558+
if dry_run:
559+
LOG.info("Pull-request would be created.")
560+
return
552561
# Create a pull request
553562
if force_editor or not (title and message):
554563
nb_of_commits, git_title, git_message = git_get_title_and_message(

0 commit comments

Comments
 (0)