Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 590cafa

Browse files
committed
fetchTree
1 parent e274685 commit 590cafa

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Sources/Classes/Git/Client+Git.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,25 @@ import RxSwift
1111

1212
public extension Client {
1313

14+
// Fetches the tree for the given reference.
15+
//
16+
// reference - The SHA, branch, reference, or tag to fetch. May be nil, in
17+
// which case HEAD is fetched.
18+
// repository - The repository from which the tree should be fetched. Cannot be
19+
// nil.
20+
// recursive - Should the tree be fetched recursively?
21+
//
22+
// Returns a signal which will send an OCTTree and complete or error.
23+
public func fetchTree(reference: String = "HEAD", repository: Repository, recursive: Bool = false) -> Observable<Tree> {
24+
let requestDescriptor = RequestDescriptor().then {
25+
$0.path = "repos/\(repository.ownerLogin)/\(repository.name)/git/trees/\(reference)"
26+
if recursive {
27+
$0.parameters["recursive"] = true
28+
}
29+
}
30+
31+
return enqueue(requestDescriptor).map {
32+
return Parser.one($0.jsonArray)
33+
}
34+
}
1435
}

0 commit comments

Comments
 (0)