diff options
author | Harald Braumann <harry@unheit.net> | 2008-02-23 21:45:00 +0100 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2008-02-23 21:45:00 +0100 |
commit | 4f4af28050d11d21300b59917893cc48f87fa562 (patch) | |
tree | 03db4e1feaea58751b66adc98f1997fa2831c89b /gbp | |
parent | 5082194530a089312b9fda1d62d800c834f224ab (diff) | |
download | git-buildpackage-4f4af28050d11d21300b59917893cc48f87fa562.tar.gz git-buildpackage-4f4af28050d11d21300b59917893cc48f87fa562.tar.bz2 git-buildpackage-4f4af28050d11d21300b59917893cc48f87fa562.zip |
Allow multiple file filters for git-import-{orig,dsc}
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/command_wrappers.py | 12 | ||||
-rw-r--r-- | gbp/config.py | 9 |
2 files changed, 14 insertions, 7 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py index 42177e56..f11d4860 100644 --- a/gbp/command_wrappers.py +++ b/gbp/command_wrappers.py @@ -87,17 +87,17 @@ class PristineTar(Command): class UnpackTarArchive(Command): """Wrap tar to Unpack a gzipped tar archive""" - def __init__(self, archive, dir, filter=""): + def __init__(self, archive, dir, filters=[]): self.archive = archive self.dir = dir - exclude = [ "", "--exclude=%s" % filter ][len(filter) > 0] + exclude = [("--exclude=%s" % filter) for filter in filters] if archive.lower().endswith(".bz2"): decompress = "--bzip2" else: decompress = "--gzip" - Command.__init__(self, 'tar', [ exclude, '-C', dir, decompress, '-xf', archive ]) + Command.__init__(self, 'tar', exclude + ['-C', dir, decompress, '-xf', archive ]) self.run_error = "Couldn't unpack %s" % self.archive @@ -222,7 +222,7 @@ class GitCommitAll(GitCommand): GitCommand.__call__(self, args) -def copy_from(orig_dir, filter=""): +def copy_from(orig_dir, filters=[]): """ copy a source tree over via tar @param orig_dir: where to copy from @@ -230,10 +230,10 @@ def copy_from(orig_dir, filter=""): @return: list of copied files @rtype: list """ - exclude = [ "", "--exclude=%s" % filter ][len(filter) > 0] + exclude = [("--exclude=%s" % filter) for filter in filters] try: - p1 = subprocess.Popen(["tar", exclude, "-cSpf", "-", "." ], stdout=subprocess.PIPE, cwd=orig_dir) + p1 = subprocess.Popen(["tar"] + exclude + ["-cSpf", "-", "." ], stdout=subprocess.PIPE, cwd=orig_dir) p2 = subprocess.Popen(["tar", "-xvSpf", "-" ], stdin=p1.stdout, stdout=subprocess.PIPE) files = p2.communicate()[0].split('\n') except OSError, err: diff --git a/gbp/config.py b/gbp/config.py index 6e1d5fa0..c18fc283 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -34,7 +34,7 @@ class GbpOptionParser(OptionParser): 'posttag' : '', 'debian-tag' : 'debian/%(version)s', 'upstream-tag' : 'upstream/%(version)s', - 'filter' : '', + 'filter' : [], 'snapshot-number' : 'snapshot + 1', 'git-log' : '--no-merges', 'export-dir' : '', @@ -52,6 +52,13 @@ class GbpOptionParser(OptionParser): self.config = dict(parser.defaults()) if parser.has_section(self.command): self.config.update(dict(parser.items(self.command, raw=True))) + # filter can be either a list or a string, always build a list: + if self.config['filter']: + if self.config['filter'].startswith('['): + self.config['filter'] = eval(self.config['filter']) + else: + self.config['filter'] = [ self.config['filter'] ] + def __init__(self, command, prefix='', usage=None): self.command = command |