Skip to content

Commit 451c2cf

Browse files
committed
Fix for issue #68 -> Add ability for GitApi.getRepositories() to include hidden repositories
1 parent bbf416f commit 451c2cf

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

azd/src/main/java/org/azd/git/GitApi.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,57 @@ public Repositories getRepositories() throws AzDException {
148148
return MAPPER.mapJsonResponse(r, Repositories.class);
149149
}
150150

151+
/***
152+
* Retrieve git repositories.
153+
* @param includeHidden If true then includes hidden repositories.
154+
* @throws AzDException Default Api Exception handler.
155+
* @return array of git repositories
156+
*/
157+
@Override
158+
public Repositories getRepositories(boolean includeHidden) throws AzDException {
159+
String r = send(RequestMethod.GET, CONNECTION, GIT, CONNECTION.getProject(), AREA, null, "repositories",
160+
ApiVersion.GIT, Map.of("includeHidden", includeHidden), null, null);
161+
162+
return MAPPER.mapJsonResponse(r, Repositories.class);
163+
}
164+
165+
/***
166+
* Retrieve git repositories.
167+
* @param includeAllUrls If true then includes all remote URLs.
168+
* @param includeLinks Set this value to true to include reference links.
169+
* @throws AzDException Default Api Exception handler.
170+
* @return array of git repositories
171+
*/
172+
@Override
173+
public Repositories getRepositories(boolean includeLinks, boolean includeAllUrls) throws AzDException {
174+
String r = send(RequestMethod.GET, CONNECTION, GIT, CONNECTION.getProject(), AREA, null, "repositories",
175+
ApiVersion.GIT, Map.of("includeLinks", includeLinks, "includeAllUrls", includeAllUrls), null, null);
176+
177+
return MAPPER.mapJsonResponse(r, Repositories.class);
178+
}
179+
180+
/***
181+
* Retrieve git repositories.
182+
* @param includeHidden If true then includes hidden repositories.
183+
* @param includeAllUrls If true then includes all remote URLs.
184+
* @param includeLinks Set this value to true to include reference links.
185+
* @throws AzDException Default Api Exception handler.
186+
* @return array of git repositories
187+
*/
188+
@Override
189+
public Repositories getRepositories(boolean includeAllUrls, boolean includeLinks, boolean includeHidden) throws AzDException {
190+
var q = new HashMap<String, Object>(){{
191+
put("includeAllUrls", includeAllUrls);
192+
put("includeLinks", includeLinks);
193+
put("includeHidden", includeHidden);
194+
}};
195+
196+
String r = send(RequestMethod.GET, CONNECTION, GIT, CONNECTION.getProject(), AREA, null, "repositories",
197+
ApiVersion.GIT, q, null, null);
198+
199+
return MAPPER.mapJsonResponse(r, Repositories.class);
200+
}
201+
151202
/***
152203
* Recover a soft-deleted Git repository. Recently deleted repositories go
153204
* into a soft-delete state for a period of time before they are hard

azd/src/main/java/org/azd/interfaces/GitDetails.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public interface GitDetails {
2424

2525
Repositories getRepositories() throws AzDException;
2626

27+
Repositories getRepositories(boolean includeHidden) throws AzDException;
28+
29+
Repositories getRepositories(boolean includeLinks, boolean includeAllUrls) throws AzDException;
30+
31+
Repositories getRepositories(boolean includeAllUrls, boolean includeLinks, boolean includeHidden) throws AzDException;
32+
2733
GitRepository restoreRepositoryFromRecycleBin(String repositoryId, boolean deleted) throws AzDException;
2834

2935
GitRepository updateRepository(String repositoryId, String repositoryName, String defaultBranchName)

azd/src/test/java/org/azd/GitApiTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ public void shouldGetRepositories() throws AzDException {
7878
g.getRepositories();
7979
}
8080

81+
@Test
82+
public void shouldGetRepositoriesForGivenQueryParameters() throws AzDException {
83+
g.getRepositories(true, true, true).getRepositories().get(0).getValidRemoteUrls();
84+
}
85+
8186
@Test(expected = AzDException.class)
8287
public void shouldRestoreRepositoryFromRecycleBin() throws AzDException {
8388
g.restoreRepositoryFromRecycleBin("00000000-0000-0000-0000-000000000000", false);

0 commit comments

Comments
 (0)