GitRepository.pull: Add 'all_remotes' option
authorLingchaox Xin <lingchaox.xin@intel.com>
Fri, 5 Jul 2013 09:50:48 +0000 (17:50 +0800)
committerGuido Günther <agx@sigxcpu.org>
Tue, 10 Sep 2013 07:18:11 +0000 (09:18 +0200)
Also changes the method to utilize the GitArgs class.

Signed-off-by: Lingchaox Xin <lingchaox.xin@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/git/repository.py
tests/test_GitRepository.py

index 9a67abf18628f0d62117cc70105aa80da7b310a3..fc7857b97226359ee2e340cddeb44c0be2b66d66 100644 (file)
@@ -1063,7 +1063,7 @@ class GitRepository(object):
 
         self._git_command("fetch", args.args)
 
-    def pull(self, repo=None, ff_only=False):
+    def pull(self, repo=None, ff_only=False, all_remotes=False):
         """
         Fetch and merge from another repository
 
@@ -1071,11 +1071,16 @@ class GitRepository(object):
         @type repo: C{str}
         @param ff_only: only merge if this results in a fast forward merge
         @type ff_only: C{bool}
+        @param all_remotes: fetch all remotes
+        @type all_remotes: C{bool}
         """
-        args = []
-        args += [ '--ff-only' ] if ff_only else []
-        args += [ repo ] if repo else []
-        self._git_command("pull", args)
+        args = GitArgs()
+        args.add_true(ff_only, '--ff-only')
+        if all_remotes:
+            args.add_true(all_remotes, '--all')
+        else:
+            args.add_true(repo, repo)
+        self._git_command("pull", args.args)
 
     def push(self, repo=None, src=None, dst=None, ff_only=True, force=False,
              tags=False):
index b12f8d41e949b1e53bdce10dccccef6fb259a0ba..f48db0a9caa857d14f931bbbd0045903a4764f4c 100644 (file)
@@ -595,6 +595,8 @@ def test_pull():
     >>> clone = gbp.git.GitRepository(d)
     >>> clone.set_branch('master')
     >>> clone.pull()
+    >>> clone.pull(all_remotes=True)
+    >>> clone.pull('origin', all_remotes=True)
     """
 
 def test_fetch():