Skip to content

Commit aa1b156

Browse files
committed
Added 'path' keyword argument to Repo.archive().
This allows sub-trees to be archived as well, and makes `.archive()` feature complete. Fixes #67
1 parent 619c989 commit aa1b156

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

‎doc/source/changes.rst

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Changelog
55
0.3.6 - Features
66
================
77
* Added `Repo.merge_base()` implementation. See the `respective issue on github <https://github.com/gitpython-developers/GitPython/issues/169>`_
8+
* `[include]` sections in git configuration files are now respected
89
* A list of all issues can be found here: https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v0.3.6+-+Features%22+
910

1011
0.3.5 - Bugfixes

‎git/repo/base.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,10 @@ def archive(self, ostream, treeish=None, prefix=None, **kwargs):
846846
:parm kwargs:
847847
Additional arguments passed to git-archive
848848
NOTE: Use the 'format' argument to define the kind of format. Use
849-
specialized ostreams to write any format supported by python
849+
specialized ostreams to write any format supported by python.
850+
851+
You may specify the special 'path' keyword, which may either be a repository-relative
852+
path to a directory or file to place into the archive, or a list or tuple of multipe paths.
850853
851854
:raise GitCommandError: in case something went wrong
852855
:return: self"""
@@ -855,8 +858,12 @@ def archive(self, ostream, treeish=None, prefix=None, **kwargs):
855858
if prefix and 'prefix' not in kwargs:
856859
kwargs['prefix'] = prefix
857860
kwargs['output_stream'] = ostream
861+
path = kwargs.pop('path', list())
862+
if not isinstance(path, (tuple, list)):
863+
path = [path]
864+
# end assure paths is list
858865

859-
self.git.archive(treeish, **kwargs)
866+
self.git.archive(treeish, *path, **kwargs)
860867
return self
861868

862869
rev_parse = rev_parse

‎git/test/test_repo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def test_tag(self):
266266
def test_archive(self):
267267
tmpfile = tempfile.mktemp(suffix='archive-test')
268268
stream = open(tmpfile, 'wb')
269-
self.rorepo.archive(stream, '0.1.5')
269+
self.rorepo.archive(stream, '0.1.6', path='doc')
270270
assert stream.tell()
271271
stream.close()
272272
os.remove(tmpfile)

0 commit comments

Comments
 (0)