Skip to content

Commit 460f2d6

Browse files
committed
Add recursive parameter to tree
Closes sigmavirus24#656
1 parent bb40e7e commit 460f2d6

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
@@ -2352,11 +2352,13 @@ def topics(self):
23522352
json = self._json(self._get(url, headers=self.PREVIEW_HEADERS), 200)
23532353
return self._instance_or_null(topics.Topics, json)
23542354

2355-
def tree(self, sha):
2355+
def tree(self, sha, recursive=False):
23562356
"""Get a tree.
23572357
23582358
:param str sha:
23592359
(required), sha of the object for this tree
2360+
:param bool recursive:
2361+
(optional), whether to fetch the tree recursively
23602362
:returns:
23612363
the tree
23622364
:rtype:
@@ -2365,7 +2367,8 @@ def tree(self, sha):
23652367
json = None
23662368
if sha:
23672369
url = self._build_url('git', 'trees', sha, base_url=self._api)
2368-
json = self._json(self._get(url), 200)
2370+
params = {'recursive': 1} if recursive else None
2371+
json = self._json(self._get(url, params=params), 200)
23692372
return self._instance_or_null(git.Tree, json)
23702373

23712374
def weekly_commit_count(self):

0 commit comments

Comments
 (0)