summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/utils/JGitUtils.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-01-09 20:49:34 -0500
committerJames Moger <james.moger@gitblit.com>2012-01-09 20:49:34 -0500
commit11924dc5db4bc44cb32e905700a8557124b1fd56 (patch)
tree610fbdf40ef312a5b2512864ae381838efa38e11 /src/com/gitblit/utils/JGitUtils.java
parent6d874a0cb27092a1c7c3eae3dfe660ffcd8d48e6 (diff)
downloadgitblit-11924dc5db4bc44cb32e905700a8557124b1fd56.tar.gz
gitblit-11924dc5db4bc44cb32e905700a8557124b1fd56.zip
Support for gh-pages branch serving as /pages/repo.git
Diffstat (limited to 'src/com/gitblit/utils/JGitUtils.java')
-rw-r--r--src/com/gitblit/utils/JGitUtils.java33
1 files changed, 33 insertions, 0 deletions
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.