From 182f194b7a7ff5b0991b8ad9f3deb23650089913 Mon Sep 17 00:00:00 2001 From: Markus Fömpe Date: Tue, 24 Jan 2017 11:54:01 +0100 Subject: New rpc endpoint for listing all branches from a given repository --- src/main/java/com/gitblit/Constants.java | 2 +- src/main/java/com/gitblit/servlet/RpcServlet.java | 12 ++++++++++++ src/site/rpc.mkd | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gitblit/Constants.java b/src/main/java/com/gitblit/Constants.java index ab503bd3..cd379b34 100644 --- a/src/main/java/com/gitblit/Constants.java +++ b/src/main/java/com/gitblit/Constants.java @@ -410,7 +410,7 @@ public class Constants { // Order is important here. anything after LIST_SETTINGS requires // administrator privileges and web.allowRpcManagement. CLEAR_REPOSITORY_CACHE, REINDEX_TICKETS, GET_PROTOCOL, LIST_REPOSITORIES, LIST_BRANCHES, GET_USER, - FORK_REPOSITORY, LIST_SETTINGS, + FORK_REPOSITORY, LIST_REPOSITORY_BRANCHES, LIST_SETTINGS, CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY, LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER, LIST_TEAMS, CREATE_TEAM, EDIT_TEAM, DELETE_TEAM, diff --git a/src/main/java/com/gitblit/servlet/RpcServlet.java b/src/main/java/com/gitblit/servlet/RpcServlet.java index 9809a252..025be440 100644 --- a/src/main/java/com/gitblit/servlet/RpcServlet.java +++ b/src/main/java/com/gitblit/servlet/RpcServlet.java @@ -328,6 +328,18 @@ public class RpcServlet extends JsonServlet { Collection permissions = deserialize(request, response, RpcUtils.REGISTRANT_PERMISSIONS_TYPE); result = gitblit.setTeamAccessPermissions(model, permissions); + } else if (RpcRequest.LIST_REPOSITORY_BRANCHES.equals(reqType)) { + + // list all branches for the given repository + Repository repository = gitblit.getRepository(objectName); + List refs = JGitUtils.getLocalBranches(repository, false, -1); + + List branches = new ArrayList<>(); + for (RefModel ref : refs) { + branches.add(ref.getName()); + } + repository.close(); + result = branches; } else if (RpcRequest.LIST_FEDERATION_REGISTRATIONS.equals(reqType)) { // return the list of federation registrations if (allowAdmin) { diff --git a/src/site/rpc.mkd b/src/site/rpc.mkd index 4b065bf0..e04b0adc 100644 --- a/src/site/rpc.mkd +++ b/src/site/rpc.mkd @@ -62,6 +62,7 @@ The Gitblit API includes methods for retrieving and interpreting RSS feeds. The Gitblit v1.3.16 Gitblit v1.4.07 Gitblit v1.6.08 +Gitblit v1.9.09 @@ -104,6 +105,7 @@ Use *SET_REPOSITORY_TEAM_PERMISSIONS* instead. SET_REPOSITORY_TEAMSrepository nameadmin2List<String>- LIST_REPOSITORY_TEAM_PERMISSIONSrepository nameadmin5-List<String> SET_REPOSITORY_TEAM_PERMISSIONSrepository nameadmin5List<String>- +LIST_REPOSITORY_BRANCHESrepository name-9-List<String> LIST_SETTINGS-admin1-ServerSettings (management keys) CLEAR_REPOSITORY_CACHE--4-- REINDEX_TICKETSrepository name-7-- -- cgit v1.2.3