From 2a02f843771aaccea2cb497fdc40ae8ca384d498 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 18 Nov 2011 17:39:37 -0500
Subject: [PATCH] Added some flare to the console log
---
src/com/gitblit/utils/RpcUtils.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/src/com/gitblit/utils/RpcUtils.java b/src/com/gitblit/utils/RpcUtils.java
index 6572cd9..387433a 100644
--- a/src/com/gitblit/utils/RpcUtils.java
+++ b/src/com/gitblit/utils/RpcUtils.java
@@ -27,10 +27,10 @@
import com.gitblit.models.FederationModel;
import com.gitblit.models.FederationProposal;
import com.gitblit.models.FederationSet;
+import com.gitblit.models.FeedModel;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.ServerSettings;
import com.gitblit.models.ServerStatus;
-import com.gitblit.models.SettingModel;
import com.gitblit.models.UserModel;
import com.google.gson.reflect.TypeToken;
@@ -45,7 +45,7 @@
public static final Type NAMES_TYPE = new TypeToken<Collection<String>>() {
}.getType();
- public static final Type SETTINGS_TYPE = new TypeToken<Collection<SettingModel>>() {
+ public static final Type SETTINGS_TYPE = new TypeToken<Map<String, String>>() {
}.getType();
private static final Type REPOSITORIES_TYPE = new TypeToken<Map<String, RepositoryModel>>() {
@@ -61,6 +61,9 @@
}.getType();
private static final Type SETS_TYPE = new TypeToken<Collection<FederationSet>>() {
+ }.getType();
+
+ private static final Type BRANCHES_TYPE = new TypeToken<Map<String, Collection<String>>>() {
}.getType();
/**
@@ -143,6 +146,10 @@
*/
public static boolean createRepository(RepositoryModel repository, String serverUrl,
String account, char[] password) throws IOException {
+ // ensure repository name ends with .git
+ if (!repository.name.endsWith(".git")) {
+ repository.name += ".git";
+ }
return doAction(RpcRequest.CREATE_REPOSITORY, null, repository, serverUrl, account,
password);
@@ -387,6 +394,48 @@
}
/**
+ * Retrieves a map of local branches in the Gitblit server keyed by
+ * repository.
+ *
+ * @param serverUrl
+ * @param account
+ * @param password
+ * @return
+ * @throws IOException
+ */
+ public static Map<String, Collection<String>> getBranches(String serverUrl, String account,
+ char[] password) throws IOException {
+ String url = asLink(serverUrl, RpcRequest.LIST_BRANCHES);
+ Map<String, Collection<String>> branches = JsonUtils.retrieveJson(url, BRANCHES_TYPE,
+ account, password);
+ return branches;
+ }
+
+ /**
+ * Retrieves a list of available branch feeds in the Gitblit server.
+ *
+ * @param serverUrl
+ * @param account
+ * @param password
+ * @return
+ * @throws IOException
+ */
+ public static List<FeedModel> getBranchFeeds(String serverUrl, String account, char[] password)
+ throws IOException {
+ List<FeedModel> feeds = new ArrayList<FeedModel>();
+ Map<String, Collection<String>> allBranches = getBranches(serverUrl, account, password);
+ for (Map.Entry<String, Collection<String>> entry : allBranches.entrySet()) {
+ for (String branch : entry.getValue()) {
+ FeedModel feed = new FeedModel();
+ feed.repository = entry.getKey();
+ feed.branch = branch;
+ feeds.add(feed);
+ }
+ }
+ return feeds;
+ }
+
+ /**
* Do the specified administrative action on the Gitblit server.
*
* @param request
--
Gitblit v1.9.1