Skip to content

Commit fcaec81

Browse files
committed
Review Repository.write_archive
1 parent 673fda4 commit fcaec81

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pygit2/repository.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -1166,18 +1166,17 @@ def write_archive(self, treeish, archive, timestamp=None, prefix=''):
11661166
Example::
11671167
11681168
>>> import tarfile, pygit2
1169-
>>>> with tarfile.open('foo.tar', 'w') as archive:
1170-
>>>> repo = pygit2.Repository('.')
1171-
>>>> repo.write_archive(repo.head.target, archive)
1169+
>>> with tarfile.open('foo.tar', 'w') as archive:
1170+
>>> repo = pygit2.Repository('.')
1171+
>>> repo.write_archive(repo.head.target, archive)
11721172
"""
11731173

11741174
# Try to get a tree form whatever we got
1175-
if isinstance(treeish, Tree):
1176-
tree = treeish
1177-
11781175
if isinstance(treeish, (str, Oid)):
11791176
treeish = self[treeish]
11801177

1178+
tree = treeish.peel(Tree)
1179+
11811180
# if we don't have a timestamp, try to get it from a commit
11821181
if not timestamp:
11831182
try:
@@ -1190,8 +1189,6 @@ def write_archive(self, treeish, archive, timestamp=None, prefix=''):
11901189
if not timestamp:
11911190
timestamp = int(time())
11921191

1193-
tree = treeish.peel(Tree)
1194-
11951192
index = Index()
11961193
index.read_tree(tree)
11971194

0 commit comments

Comments
 (0)