Skip to content

Commit cd7f085

Browse files
authored
Merge pull request sigmavirus24#861 from jacquerie/add-recursive-parameter-to-tree
Add recursive parameter to tree
2 parents 3cd8d0e + 460f2d6 commit cd7f085

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

github3/repos/repo.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,11 +2358,13 @@ def topics(self):
23582358
json = self._json(self._get(url, headers=self.PREVIEW_HEADERS), 200)
23592359
return self._instance_or_null(topics.Topics, json)
23602360

2361-
def tree(self, sha):
2361+
def tree(self, sha, recursive=False):
23622362
"""Get a tree.
23632363
23642364
:param str sha:
23652365
(required), sha of the object for this tree
2366+
:param bool recursive:
2367+
(optional), whether to fetch the tree recursively
23662368
:returns:
23672369
the tree
23682370
:rtype:
@@ -2371,7 +2373,8 @@ def tree(self, sha):
23712373
json = None
23722374
if sha:
23732375
url = self._build_url('git', 'trees', sha, base_url=self._api)
2374-
json = self._json(self._get(url), 200)
2376+
params = {'recursive': 1} if recursive else None
2377+
json = self._json(self._get(url, params=params), 200)
23752378
return self._instance_or_null(git.Tree, json)
23762379

23772380
def weekly_commit_count(self):

0 commit comments

Comments
 (0)