]> source.dussan.org Git - gitblit.git/commitdiff
New rpc endpoint for listing all branches from a given repository 1186/head
authorMarkus Fömpe <markus.foempe@gmail>
Tue, 24 Jan 2017 10:54:01 +0000 (11:54 +0100)
committerMarkus Fömpe <markus.foempe@gmail.com>
Wed, 25 Jan 2017 13:58:08 +0000 (14:58 +0100)
src/main/java/com/gitblit/Constants.java
src/main/java/com/gitblit/servlet/RpcServlet.java
src/site/rpc.mkd

index ab503bd392ccf9297ee68dc95ae2859baae3fa2b..cd379b3457df7da79350fb427e12110156bcb67b 100644 (file)
@@ -410,7 +410,7 @@ public class Constants {
                // Order is important here.  anything after LIST_SETTINGS requires\r
                // administrator privileges and web.allowRpcManagement.\r
                CLEAR_REPOSITORY_CACHE, REINDEX_TICKETS, GET_PROTOCOL, LIST_REPOSITORIES, LIST_BRANCHES, GET_USER,\r
-               FORK_REPOSITORY, LIST_SETTINGS,\r
+               FORK_REPOSITORY, LIST_REPOSITORY_BRANCHES, LIST_SETTINGS,\r
                CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY,\r
                LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER,\r
                LIST_TEAMS, CREATE_TEAM, EDIT_TEAM, DELETE_TEAM,\r
index 9809a2525e5f99906849c8806838afec831ecaec..025be4406699b439136c6edd739483aa4fefaa85 100644 (file)
@@ -328,6 +328,18 @@ public class RpcServlet extends JsonServlet {
                        Collection<RegistrantAccessPermission> permissions = deserialize(request, response,\r
                                        RpcUtils.REGISTRANT_PERMISSIONS_TYPE);\r
                        result = gitblit.setTeamAccessPermissions(model, permissions);\r
+               } else if (RpcRequest.LIST_REPOSITORY_BRANCHES.equals(reqType)) {\r
+\r
+                       // list all branches for the given repository           \r
+                       Repository repository = gitblit.getRepository(objectName);\r
+                       List<RefModel> refs = JGitUtils.getLocalBranches(repository, false, -1);\r
+\r
+                       List<String> branches = new ArrayList<>();\r
+                       for (RefModel ref : refs) {\r
+                               branches.add(ref.getName());\r
+                       }\r
+                       repository.close();\r
+                       result = branches;\r
                } else if (RpcRequest.LIST_FEDERATION_REGISTRATIONS.equals(reqType)) {\r
                        // return the list of federation registrations\r
                        if (allowAdmin) {\r
index 4b065bf05c89bfdbd6949336d2eff90ce902940d..e04b0adc337624a7b6899319f79c745db8bc5958 100644 (file)
@@ -62,6 +62,7 @@ The Gitblit API includes methods for retrieving and interpreting RSS feeds.  The
 <tr><td>Gitblit v1.3.1</td><td>6</td></tr>\r
 <tr><td>Gitblit v1.4.0</td><td>7</td></tr>\r
 <tr><td>Gitblit v1.6.0</td><td>8</td></tr>\r
+<tr><td>Gitblit v1.9.0</td><td>9</td></tr>\r
 </tbody>\r
 </table>\r
 \r
@@ -104,6 +105,7 @@ Use *SET_REPOSITORY_TEAM_PERMISSIONS* instead.
 <tr><td><s>SET_REPOSITORY_TEAMS</s></td><td><s>repository name</s></td><td><em><s>admin</s></em></td><td><s>2</s></td><td><s>List&lt;String&gt;</s></td><td>-</td></tr>\r
 <tr><td>LIST_REPOSITORY_TEAM_PERMISSIONS</td><td>repository name</td><td><em>admin</em></td><td>5</td><td>-</td><td>List&lt;String&gt;</td></tr>\r
 <tr><td>SET_REPOSITORY_TEAM_PERMISSIONS</td><td>repository name</td><td><em>admin</em></td><td>5</td><td>List&lt;String&gt;</td><td>-</td></tr>\r
+<tr><td>LIST_REPOSITORY_BRANCHES</td><td>repository name</td><td><em>-</em></td><td>9</td><td>-</td><td>List&lt;String&gt;</td></tr>\r
 <tr><td>LIST_SETTINGS</td><td>-</td><td><em>admin</em></td><td>1</td><td>-</td><td>ServerSettings (management keys)</td></tr>\r
 <tr><td>CLEAR_REPOSITORY_CACHE</td><td>-</td><td><em>-</em></td><td>4</td><td>-</td><td>-</td></tr>\r
 <tr><td>REINDEX_TICKETS</td><td>repository name</td><td><em>-</em></td><td>7</td><td>-</td><td>-</td></tr>\r