diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-10-24 17:20:19 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-10-26 09:45:10 +0200 |
commit | 02efee70bf88c2c87886efa6aad57bad924a508e (patch) | |
tree | 460b043dcab21a4952a34769c20f5e25730b6202 | |
parent | 113ac4ed020c3bf65dbf7517599a8105c521bf91 (diff) |
Add GitRepository.add_remote_repo()
-rwxr-xr-x | gbp-create-remote-repo | 4 | ||||
-rw-r--r-- | gbp/git.py | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/gbp-create-remote-repo b/gbp-create-remote-repo index fa105d1..84bac66 100755 --- a/gbp-create-remote-repo +++ b/gbp-create-remote-repo @@ -131,9 +131,7 @@ def read_yn(): def setup_branch_tracking(repo, remote, branches): - gitRemoteAdd = GitCommand('remote', ['add']) - gitRemoteAdd([remote['name'], remote['url']]) - repo.fetch(remote['name']) + repo.add_remote_repo(name=remote['name'], url=remote['url'], fetch=True) gitTrackRemote = GitCommand('branch', ['--set-upstream']) for branch in branches: gitTrackRemote(['%s' % branch, '%s/%s' % (remote['name'], branch)]) @@ -710,6 +710,24 @@ class GitRepository(object): else: return False + def add_remote_repo(self, name, url, tags=True, fetch=False): + """ + Add a tracked remote repository + + @param name: the name to use for the remote + @type name: string + @param url: the url to add + @type url: string + @param tags: whether to fetch tags + @type tags: bool + @param fetch: whether to fetch immediately from the remote side + @type fetch: bool + """ + args = [ "add" ] + args += [ '--tags' ] if tags else [ '--no-tags'] + args += [ '--fetch' ] if fetch else [] + args += [ name, url ] + self._git_command("remote", args) def add_files(self, paths, force=False, index_file=None, work_tree=None): """ |