Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/com/spotify/github/v3/clients/GitDataClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ public CompletableFuture<Tree> getTree(final String sha) {
return github.request(path, Tree.class);
}

/**
* Get a repository tree recursively.
*
* @param sha commit sha
* @return tree
*/
public CompletableFuture<Tree> getRecursiveTree(final String sha) {
final String path = String.format(TREE_SHA_URI_TEMPLATE, owner, repo, sha);
return github.request(path + "?recursive=true", Tree.class);
}

/**
* Set a repository tree.
*
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/com/spotify/github/v3/clients/GitDataClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,22 @@ public void testGetTree() throws IOException {
assertThat(tree.sha(), is("9c27bd92524e2b57b569d4c86695b3993d9b8f9f"));
}

@Test
public void testGetRecursiveTree() throws IOException {
final CompletableFuture<Tree> fixture =
completedFuture(json.fromJson(getFixture("recursive-tree.json"), Tree.class));

when(github.request("/repos/someowner/somerepo/git/trees/thesha", Tree.class))
.thenReturn(fixture);

final Tree tree =
gitDataClient
.getTree("thesha")
.join();
assertThat(tree.sha(), is("9c27bd92524e2b57b569d4c86695b3993d9b8f9f"));
assertThat(tree.tree().size(), is(7));
}

@Test
public void testCreateTree() throws IOException {
final TreeItem treeItem =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"sha": "9c27bd92524e2b57b569d4c86695b3993d9b8f9f",
"url": "https://ghe.spotify.net/api/v3/repos/ugc-sharing/test-repo/git/trees/9c27bd92524e2b57b569d4c86695b3993d9b8f9f",
"tree": [
{
"path": "README.md",
"mode": "100644",
"type": "blob",
"sha": "6e091fd045dc88806e5c70357326af7fa0e1ccde",
"size": 12,
"url": "https://ghe.spotify.net/api/v3/repos/ugc-sharing/test-repo/git/blobs/6e091fd045dc88806e5c70357326af7fa0e1ccde"
},
{
"path": "UserGeneratedContentUtils.java",
"mode": "100644",
"type": "blob",
"sha": "77b3e188803e717a0a5ce53b818b0ed6fb6b8a23",
"size": 5340,
"url": "https://ghe.spotify.net/api/v3/repos/ugc-sharing/test-repo/git/blobs/77b3e188803e717a0a5ce53b818b0ed6fb6b8a23"
},
{
"path": "readme.md",
"mode": "100644",
"type": "blob",
"sha": "f09eac953086b8760f600822f057141d7b311165",
"size": 29,
"url": "https://ghe.spotify.net/api/v3/repos/ugc-sharing/test-repo/git/blobs/f09eac953086b8760f600822f057141d7b311165"
},
{
"path": "src",
"mode": "040000",
"type": "tree",
"sha": "26cd96e1394d6c4982d8cec879ad4fefa423bec8",
"url": "https://ghe.spotify.net/api/v3/repos/ugc-sharing/test-repo/git/trees/26cd96e1394d6c4982d8cec879ad4fefa423bec8"
},
{
"path": "src/public",
"mode": "040000",
"type": "tree",
"sha": "a296470ebb9709103115d6e21d9bc54cdfc8b120",
"url": "https://ghe.spotify.net/api/v3/repos/ugc-sharing/test-repo/git/trees/a296470ebb9709103115d6e21d9bc54cdfc8b120"
},
{
"path": "src/public/UserGeneratedContentUtils.java",
"mode": "100644",
"type": "blob",
"sha": "77b3e188803e717a0a5ce53b818b0ed6fb6b8a23",
"size": 5340,
"url": "https://ghe.spotify.net/api/v3/repos/ugc-sharing/test-repo/git/blobs/77b3e188803e717a0a5ce53b818b0ed6fb6b8a23"
},
{
"path": "src/public/test.txt",
"mode": "100644",
"type": "blob",
"sha": "c57eff55ebc0c54973903af5f72bac72762cf4f4",
"size": 12,
"url": "https://ghe.spotify.net/api/v3/repos/ugc-sharing/test-repo/git/blobs/c57eff55ebc0c54973903af5f72bac72762cf4f4"
}
],
"truncated": false
}