Skip to content

Commit 2eb0bb9

Browse files
Lirickmarthasthenriquetruta
authored
Add the old list reference methods (#32)
Co-authored-by: marthast <marthast@spotify.com> Co-authored-by: Henrique <henriquecostatruta@gmail.com>
1 parent b0b83c9 commit 2eb0bb9

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

src/main/java/com/spotify/github/v3/clients/GitDataClient.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@ public CompletableFuture<List<Reference>> listMatchingReferences(final String re
125125
return github.request(path, LIST_REFERENCES);
126126
}
127127

128+
/**
129+
* List references. (Replaced by listMatchingReferences for github enterprise version > 2.18)
130+
*
131+
* @param ref reference name
132+
*/
133+
@Deprecated
134+
public CompletableFuture<List<Reference>> listReferences(final String ref) {
135+
final String path = format(REFERENCE_URI, owner, repo, ref.replaceAll("refs/", ""));
136+
return github.request(path, LIST_REFERENCES);
137+
}
138+
139+
/**
140+
* List references. (Replaced by listMatchingReferences for github enterprise version > 2.18)
141+
*
142+
*/
143+
@Deprecated
144+
public CompletableFuture<List<Reference>> listReferences() {
145+
return listReferences("");
146+
}
147+
148+
128149
/**
129150
* Create a git reference.
130151
*

src/test/java/com/spotify/github/v3/clients/GitDataClientTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ public void listMatchingReferences() throws Exception {
101101
}
102102
}
103103

104+
@Test
105+
public void listReferences() throws Exception {
106+
final CompletableFuture<List<Reference>> fixture =
107+
completedFuture(json.fromJson(getFixture("tags_list.json"), LIST_REFERENCES));
108+
when(github.request(
109+
"/repos/someowner/somerepo/git/refs/tags",
110+
LIST_REFERENCES))
111+
.thenReturn(fixture);
112+
final List<Reference> matchingReferences = gitDataClient.listReferences("refs/tags").get();
113+
assertThat(matchingReferences.size(), is(1));
114+
for (Reference ref : matchingReferences) {
115+
assertThat(ref.ref(), containsString("refs/tags"));
116+
}
117+
}
118+
104119

105120
public void createReference() throws Exception {
106121
final CompletableFuture<Reference> fixture =
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"ref": "refs/tags/v0.0.1",
4+
"node_id": "MDM6UmVmcmVmcy90YWdzL3YwLjAuMQ==",
5+
"url": "https://api.github.com/repos/octocat/Hello-World/git/refs/tags/v0.0.1",
6+
"object": {
7+
"type": "tag",
8+
"sha": "940bd336248efae0f9ee5bc7b2d5c985887b16ac",
9+
"url": "https://api.github.com/repos/octocat/Hello-World/git/tags/940bd336248efae0f9ee5bc7b2d5c985887b16ac"
10+
}
11+
}
12+
]

0 commit comments

Comments
 (0)