Replace GitFetch by GitRepository.fetch()
authorGuido Günther <agx@sigxcpu.org>
Sun, 23 Oct 2011 11:47:01 +0000 (13:47 +0200)
committerGuido Günther <agx@sigxcpu.org>
Sun, 23 Oct 2011 14:20:33 +0000 (16:20 +0200)
gbp-create-remote-repo
gbp-pull
gbp/command_wrappers.py
gbp/git.py

index 0653a9c..fa105d1 100755 (executable)
@@ -28,8 +28,7 @@ import subprocess
 import tty, termios
 import re
 import gbp.deb as du
-from gbp.command_wrappers import (CommandExecFailed, PristineTar, GitCommand,
-                                  GitFetch)
+from gbp.command_wrappers import (CommandExecFailed, PristineTar, GitCommand)
 from gbp.config import (GbpOptionParser, GbpOptionGroup)
 from gbp.errors import GbpError
 from gbp.git import (GitRepositoryError, GitRepository)
@@ -131,10 +130,10 @@ def read_yn():
         return False
 
 
-def setup_branch_tracking(remote, branches):
+def setup_branch_tracking(repo, remote, branches):
     gitRemoteAdd = GitCommand('remote', ['add'])
     gitRemoteAdd([remote['name'], remote['url']])
-    GitFetch()([remote['name']])
+    repo.fetch(remote['name'])
     gitTrackRemote = GitCommand('branch', ['--set-upstream'])
     for branch in branches:
         gitTrackRemote(['%s' % branch, '%s/%s' % (remote['name'], branch)])
@@ -231,7 +230,7 @@ echo "%(pkg)s packaging" > description
 
         push_branches(remote, branches)
         if options.track:
-            setup_branch_tracking(remote, branches)
+            setup_branch_tracking(repo, remote, branches)
         else:
             gbp.log.info("You can now add:")
             print_config(remote, branches)
index 8bb9ba5..cb7d5ef 100755 (executable)
--- a/gbp-pull
+++ b/gbp-pull
@@ -22,7 +22,7 @@
 
 import sys
 import os, os.path
-from gbp.command_wrappers import (GitFetch, Command,
+from gbp.command_wrappers import (Command,
                                   CommandExecFailed, PristineTar)
 from gbp.config import (GbpOptionParser, GbpOptionGroup)
 from gbp.errors import GbpError
@@ -109,7 +109,7 @@ def main(argv):
             gbp.log.err(out)
             raise GbpError
 
-        GitFetch()()
+        repo.fetch()
         for branch in branches:
             if not fast_forward_branch(branch, repo, options):
                 retval = 2
index 1fcfdbc..33d6823 100644 (file)
@@ -230,16 +230,6 @@ class GitCommand(Command):
         self.run_error = "Couldn't run git %s" % cmd
 
 
-# FIXME: move to gbp.git.fetch
-class GitFetch(GitCommand):
-    """Wrap git fetch"""
-    def __init__(self, remote = None):
-        opts = []
-        if remote:
-            opts += [remote]
-        GitCommand.__init__(self, 'fetch', opts)
-
-
 # FIXME: move to gbp.git.create_tag
 class GitTag(GitCommand):
     """Wrap git tag"""
index cb3d74b..7566635 100644 (file)
@@ -785,6 +785,17 @@ class GitRepository(object):
         if ret:
             raise GitRepositoryError, "unable to archive %s"%(treeish)
 
+    def fetch(self, repo=None):
+        """
+        Download objects and refs from another repository.
+
+        param repo: repository to fetch from
+        type repo: string
+        """
+        if repo:
+            args = [repo]
+
+        self._git_command("fetch", [ args ])
 
     def has_submodules(self):
         """Does the repo have any submodules?"""