From aa1b156ee96f5aabdca153c152ec6e3215fdf16f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 14 Jan 2015 16:23:17 +0100 Subject: Added 'path' keyword argument to Repo.archive(). This allows sub-trees to be archived as well, and makes `.archive()` feature complete. Fixes #67 --- git/repo/base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'git/repo/base.py') diff --git a/git/repo/base.py b/git/repo/base.py index 155a674f..afff9471 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -846,7 +846,10 @@ class Repo(object): :parm kwargs: Additional arguments passed to git-archive NOTE: Use the 'format' argument to define the kind of format. Use - specialized ostreams to write any format supported by python + specialized ostreams to write any format supported by python. + + You may specify the special 'path' keyword, which may either be a repository-relative + path to a directory or file to place into the archive, or a list or tuple of multipe paths. :raise GitCommandError: in case something went wrong :return: self""" @@ -855,8 +858,12 @@ class Repo(object): if prefix and 'prefix' not in kwargs: kwargs['prefix'] = prefix kwargs['output_stream'] = ostream + path = kwargs.pop('path', list()) + if not isinstance(path, (tuple, list)): + path = [path] + # end assure paths is list - self.git.archive(treeish, **kwargs) + self.git.archive(treeish, *path, **kwargs) return self rev_parse = rev_parse -- cgit v1.2.1