summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-02-08 13:52:47 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-02-09 16:06:17 +0000
commita87c7b616a269ee4b6b530cf5069df1423a49bd4 (patch)
tree9b4e7fb2d3c778e3e241fe764d06197008505097
parent24d0fa25530dc6dcc423f4a9eac417c60b8eb093 (diff)
downloadmorph-a87c7b616a269ee4b6b530cf5069df1423a49bd4.tar.gz
Change how git clones are created from bundles
For some reason, "git bundle unbundle" doesn't work for me, but "git clone" does. Then, adding a remote fails, because the cloned bundle already has one, so now we'll use "git remote set-url" and "git remote update".
-rw-r--r--morphlib/git.py8
-rw-r--r--morphlib/sourcemanager.py8
2 files changed, 9 insertions, 7 deletions
diff --git a/morphlib/git.py b/morphlib/git.py
index 0b774229..47de2f61 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -221,7 +221,7 @@ def get_morph_text(treeish, filename, msg=logging.debug):
def extract_bundle(location, bundle, msg=logging.debug):
'''Extract a bundle into git at location'''
ex = morphlib.execute.Execute(location, msg=msg)
- return ex.runv(['git', 'bundle', 'unbundle', bundle])
+ return ex.runv(['git', 'clone', bundle, '.'])
def clone(location, repo, msg=logging.debug):
'''clone at git repo into location'''
@@ -234,10 +234,10 @@ def init(location, msg=logging.debug):
ex = morphlib.execute.Execute(location, msg=msg)
return ex.runv(['git', 'init'])
-def add_remote(gitdir, name, url, msg=logging.debug):
- '''add remote with name 'name' for url at gitdir'''
+def set_remote(gitdir, name, url, msg=logging.debug):
+ '''Set remote with name 'name' use a given url at gitdir'''
ex = morphlib.execute.Execute(gitdir, msg=msg)
- return ex.runv(['git', 'remote', 'add', '-f', name, url])
+ return ex.runv(['git', 'remote', 'set-url', name, url])
def update_remote(gitdir, name, msg=logging.debug):
ex = morphlib.execute.Execute(gitdir, msg=msg)
diff --git a/morphlib/sourcemanager.py b/morphlib/sourcemanager.py
index bd6ec3da..b289519a 100644
--- a/morphlib/sourcemanager.py
+++ b/morphlib/sourcemanager.py
@@ -104,12 +104,14 @@ class SourceManager(object):
try:
if bundle:
self.msg('Initialising repository at %s' % location)
- morphlib.git.init(location, self.msg)
+ os.mkdir(location)
self.msg('Extracting bundle %s into %s' %
(bundle, location))
morphlib.git.extract_bundle(location, bundle, self.msg)
- self.msg('Adding origin %s' % repo)
- morphlib.git.add_remote(location,'origin', repo, self.msg)
+ self.msg('Setting origin to %s' % repo)
+ morphlib.git.set_remote(location,'origin', repo, self.msg)
+ self.msg('Updating from origin')
+ morphlib.git.update_remote(location, "origin", self.msg)
else:
self.msg('Cloning %s into %s' % (repo, location))
morphlib.git.clone(location, repo, self.msg)