summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/gitblit/utils')
-rw-r--r--src/com/gitblit/utils/ArrayUtils.java4
-rw-r--r--src/com/gitblit/utils/JGitUtils.java33
2 files changed, 37 insertions, 0 deletions
diff --git a/src/com/gitblit/utils/ArrayUtils.java b/src/com/gitblit/utils/ArrayUtils.java
index 635d27ab..d0322b6b 100644
--- a/src/com/gitblit/utils/ArrayUtils.java
+++ b/src/com/gitblit/utils/ArrayUtils.java
@@ -26,6 +26,10 @@ import java.util.Collection;
*/
public class ArrayUtils {
+ public static boolean isEmpty(byte [] array) {
+ return array == null || array.length == 0;
+ }
+
public static boolean isEmpty(Object [] array) {
return array == null || array.length == 0;
}
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index d694ee28..ae53c942 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -1284,6 +1284,39 @@ public class JGitUtils {
}
/**
+ * Returns a RefModel for the gh-pages branch in the repository. If the
+ * branch can not be found, null is returned.
+ *
+ * @param repository
+ * @return a refmodel for the gh-pages branch or null
+ */
+ public static RefModel getPagesBranch(Repository repository) {
+ RefModel ghPages = null;
+ try {
+ // search for gh-pages branch in local heads
+ for (RefModel ref : JGitUtils.getLocalBranches(repository, false, -1)) {
+ if (ref.displayName.endsWith("gh-pages")) {
+ ghPages = ref;
+ break;
+ }
+ }
+
+ // search for gh-pages branch in remote heads
+ if (ghPages == null) {
+ for (RefModel ref : JGitUtils.getRemoteBranches(repository, false, -1)) {
+ if (ref.displayName.endsWith("gh-pages")) {
+ ghPages = ref;
+ break;
+ }
+ }
+ }
+ } catch (Throwable t) {
+ LOGGER.error("Failed to find gh-pages branch!", t);
+ }
+ return ghPages;
+ }
+
+ /**
* Returns the list of notes entered about the commit from the refs/notes
* namespace. If the repository does not exist or is empty, an empty list is
* returned.