summaryrefslogtreecommitdiff
path: root/morphlib/git.py
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-02-22 13:09:48 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-02-22 13:09:48 +0000
commitaa4834c1a911600ffa26b04285eb56cc863b63de (patch)
treec027c596d08f1c821f050f48c714543908a0c9e7 /morphlib/git.py
parent18f896eb1f539497ba50ccae372a557398c6b5d4 (diff)
downloadmorph-aa4834c1a911600ffa26b04285eb56cc863b63de.tar.gz
Use "cp -a" and "git checkout" to unpack sources in the build tree.
This is done to keep the git repository intact with history and all that. cp + checkout turns out to be faster than a regular "git clone". In order to avoid roundtrips to the internet whenever a chunk tries to do something with submodules, we force the submodule URLs to point to our locally cached repos.
Diffstat (limited to 'morphlib/git.py')
-rw-r--r--morphlib/git.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/morphlib/git.py b/morphlib/git.py
index cca51eed..05a55e06 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -211,12 +211,6 @@ class Submodules(object):
return len(self.submodules)
-def export_sources(treeish, tar_filename, msg=logging.debug):
- '''Export the contents of a specific commit into a compressed tarball.'''
- ex = morphlib.execute.Execute('.', msg=msg)
- ex.env['GIT_DIR'] = os.path.join(treeish.repo, '.git')
- ex.runv(['git', 'archive', '-o', tar_filename, treeish.sha1])
-
def get_morph_text(treeish, filename, msg=logging.debug):
'''Return a morphology from a git repository.'''
ex = morphlib.execute.Execute(treeish.repo, msg=msg)
@@ -248,8 +242,19 @@ def update_remote(gitdir, name, msg=logging.debug):
ex = morphlib.execute.Execute(gitdir, msg=msg)
return ex.runv(['git', 'remote', 'update', name])
-def archive_and_extract(app, treeish, destdir, msg=logging.debug):
- return app.runcmd(['git', 'archive', treeish.ref],
- ['tar', '-C', destdir, '-xv'],
- cwd=treeish.repo,
- msg=msg)
+def copy_repository(treeish, destdir, msg=logging.debug):
+ '''Copies a cached repository into a directory using cp.'''
+ ex = morphlib.execute.Execute('.', msg=msg)
+ return ex.runv(['cp', '-a', os.path.join(treeish.repo, '.git'), destdir])
+
+def checkout_ref(gitdir, ref, msg=logging.debug):
+ '''Checks out a specific ref/SHA1 in a git working tree.'''
+ ex = morphlib.execute.Execute(gitdir, msg=msg)
+ return ex.runv(['git', 'checkout', ref])
+
+def set_submodule_url(gitdir, name, url, msg=logging.debug):
+ '''Changes the URL of a submodule to point to a specific location.'''
+ ex = morphlib.execute.Execute(gitdir, msg=msg)
+ ex.runv(['git', 'config', 'submodule.%s.url' % name, url])
+ ex.runv(['git', 'config', '-f', '.gitmodules',
+ 'submodule.%s.url' % name, url])