diff --git a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/RepositoryResource.java b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/RepositoryResource.java
index 6835953bea..2dfb40709e 100644
--- a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/RepositoryResource.java
+++ b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/RepositoryResource.java
@@ -49,6 +49,7 @@ import org.slf4j.LoggerFactory;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.repository.BlameResult;
+import sonia.scm.repository.Branches;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
@@ -393,6 +394,66 @@ public class RepositoryResource
return response;
}
+ /**
+ * Returns all {@link Branches} of a repository.
+ *
+ * Status codes:
+ *
+ * - 200 get successful
+ * - 400 bad request, the content feature is not
+ * supported by this type of repositories.
+ * - 404 not found, if the repository or the path could not be found
+ * - 500 internal server error
+ *
+ *
+ * @param id the id of the repository
+ *
+ * @return all {@link Branches} of a repository
+ *
+ * @throws IOException
+ * @throws RepositoryException
+ *
+ * @since 1.18
+ */
+ @GET
+ @Path("{id}/branches")
+ public Response getBranches(@PathParam("id") String id)
+ throws RepositoryException, IOException
+ {
+ Response response = null;
+ RepositoryService service = null;
+
+ try
+ {
+ service = servicefactory.create(id);
+
+ Branches branches = service.getBranchesCommand().getBranches();
+
+ if (branches != null)
+ {
+ response = Response.ok(branches).build();
+ }
+ else
+ {
+ response = Response.status(Status.NOT_FOUND).build();
+ }
+ }
+ catch (RepositoryNotFoundException ex)
+ {
+ response = Response.status(Response.Status.NOT_FOUND).build();
+ }
+ catch (CommandNotSupportedException ex)
+ {
+ response = Response.status(Response.Status.BAD_REQUEST).build();
+ }
+ finally
+ {
+ Closeables.closeQuietly(service);
+ }
+
+ return response;
+ }
+
/**
* Returns a list of folders and files for the given folder.
*
@@ -830,7 +891,7 @@ public class RepositoryResource
*
* @throws IOException
* @throws RepositoryException
- *
+ *
* @since 1.18
*/
@GET