diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-01-05 16:49:03 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-01-05 16:49:03 +0000 |
commit | 6fc2dd78c8325e686e6e4c267f6c8941da407da5 (patch) | |
tree | 370b387fd22f7ce7d62a2c2f67e3ab8ecaf90594 | |
parent | dc862e12b82f6697c8a1ea715851df8eee35364b (diff) | |
download | lorry-6fc2dd78c8325e686e6e4c267f6c8941da407da5.tar.gz |
Add tarball support, it's probably not really worth it
-rwxr-xr-x | lorry | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -19,6 +19,7 @@ import cliapp import json import logging import os +import urllib2 __version__ = '0.0' @@ -59,6 +60,7 @@ class Lorry(cliapp.Application): 'git': self.mirror_git, 'hg': self.gitify_hg, 'svn': self.gitify_svn, + 'tarball': self.gitify_tarball, } vcstype = spec['type'] if vcstype not in table: @@ -162,6 +164,33 @@ class Lorry(cliapp.Application): self.run_program(['hg-fast-export', '--quiet', '-r', '../hg'], cwd=gitdir) + def gitify_tarball(self, dirname, gitdir, spec): + tardest = os.path.join(dirname, 'tarball') + if not os.path.exists(tardest): + with open(tardest, 'w') as tarfile: + urlfile = urllib2.urlopen(spec['url']) + tarfile.write(urlfile.read()) + urlfile.close() + + if not os.path.exists(gitdir): + self.run_program(['git', 'init', gitdir]) + cmdline = ['tar', '--extract', '--file', tardest] + # compression is handled in long form, so use gzip instead of z + try: + cmdline += ['--' + spec['compression']] + except KeyError: + pass + # tarballs often have a directory on top, strip = 1 will remove it + try: + cmdline += ['--strip-components', str(spec['strip'])] + except KeyError: + pass + self.run_program(cmdline, cwd=gitdir) + self.run_program(['git', 'add', '.'], cwd=gitdir) + self.run_program(['git', 'commit', '-m', 'Tarball conversion'], + cwd=gitdir) + + def push_to_gitorious(self, project_name, gitdir): out = self.run_program(['git', 'remote', 'show'], cwd=gitdir) if 'gitorious' not in out.splitlines(): |