From 7ae2778b8fbeae7c13244687e22f45ad4fd1ed7f Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 30 Dec 2016 18:40:05 +0100 Subject: GitRepository: allow for dry-run push --- gbp/git/repository.py | 10 ++++++++-- tests/doctests/test_GitRepository.py | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 3ccc38a0..a1c27b1f 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1242,7 +1242,7 @@ class GitRepository(object): self._git_command("pull", args.args) def push(self, repo=None, src=None, dst=None, ff_only=True, force=False, - tags=False): + tags=False, dry_run=False): """ Push changes to the remote repo @@ -1259,11 +1259,14 @@ class GitRepository(object): @type force: C{bool} @param tags: push all refs under refs/tags, in addition to other refs @type tags: C{bool} + @param dry_run: dry run + @type dry_run: C{bool} """ args = GitArgs() args.add_cond(repo, repo) args.add_true(force, "-f") args.add_true(tags, "--tags") + args.add_true(dry_run, "--dry-run") # Allow for src == '' to delete dst on the remote if src is not None: @@ -1276,7 +1279,7 @@ class GitRepository(object): self._git_command("push", args.args) - def push_tag(self, repo, tag): + def push_tag(self, repo, tag, dry_run=False): """ Push a tag to the remote repo @@ -1284,8 +1287,11 @@ class GitRepository(object): @type repo: C{str} @param tag: the name of the tag @type tag: C{str} + @param dry_run: dry run + @type dry_run: C{bool} """ args = GitArgs(repo, 'tag', tag) + args.add_true(dry_run, "--dry-run") self._git_command("push", args.args) #{ Files diff --git a/tests/doctests/test_GitRepository.py b/tests/doctests/test_GitRepository.py index e353df84..5bc1709c 100644 --- a/tests/doctests/test_GitRepository.py +++ b/tests/doctests/test_GitRepository.py @@ -709,10 +709,12 @@ def test_fetch(): >>> clone = gbp.git.GitRepository(d) >>> clone.fetch() >>> clone.push() + >>> clone.push('origin', dry_run=True) >>> clone.push('origin') >>> clone.push('origin', 'master') >>> clone.push('origin', 'master', force=True) >>> clone.create_tag('tag3') + >>> clone.push_tag('origin', 'tag3', True) >>> clone.push_tag('origin', 'tag3') >>> clone.create_tag('tag4') >>> clone.push('origin', 'master', tags=True) -- cgit v1.2.3