summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Fömpe <markus.foempe@gmail>2017-01-24 11:54:01 +0100
committerMarkus Fömpe <markus.foempe@gmail.com>2017-01-25 14:58:08 +0100
commit182f194b7a7ff5b0991b8ad9f3deb23650089913 (patch)
tree9f51c5c4d44824456e9b90a6446e0aea52167572
parent651b9980f5b8664939b91674252d0dfdc754fed2 (diff)
downloadgitblit-182f194b7a7ff5b0991b8ad9f3deb23650089913.tar.gz
gitblit-182f194b7a7ff5b0991b8ad9f3deb23650089913.zip
New rpc endpoint for listing all branches from a given repository
-rw-r--r--src/main/java/com/gitblit/Constants.java2
-rw-r--r--src/main/java/com/gitblit/servlet/RpcServlet.java12
-rw-r--r--src/site/rpc.mkd2
3 files changed, 15 insertions, 1 deletions
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<RegistrantAccessPermission> 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<RefModel> refs = JGitUtils.getLocalBranches(repository, false, -1);
+
+ List<String> 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
<tr><td>Gitblit v1.3.1</td><td>6</td></tr>
<tr><td>Gitblit v1.4.0</td><td>7</td></tr>
<tr><td>Gitblit v1.6.0</td><td>8</td></tr>
+<tr><td>Gitblit v1.9.0</td><td>9</td></tr>
</tbody>
</table>
@@ -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>
<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>
<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>
+<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>
<tr><td>LIST_SETTINGS</td><td>-</td><td><em>admin</em></td><td>1</td><td>-</td><td>ServerSettings (management keys)</td></tr>
<tr><td>CLEAR_REPOSITORY_CACHE</td><td>-</td><td><em>-</em></td><td>4</td><td>-</td><td>-</td></tr>
<tr><td>REINDEX_TICKETS</td><td>repository name</td><td><em>-</em></td><td>7</td><td>-</td><td>-</td></tr>