James Moger
2012-01-09 cc1cd7800940f98efe206fe50a4375a3fb9dc621
src/com/gitblit/utils/JGitUtils.java
@@ -1284,6 +1284,50 @@
   }
   /**
    * 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) {
      return getBranch(repository, "gh-pages");
   }
   /**
    * Returns a RefModel for a specific branch name in the repository. If the
    * branch can not be found, null is returned.
    *
    * @param repository
    * @return a refmodel for the branch or null
    */
   public static RefModel getBranch(Repository repository, String name) {
      RefModel branch = null;
      try {
         // search for the branch in local heads
         for (RefModel ref : JGitUtils.getLocalBranches(repository, false, -1)) {
            if (ref.displayName.endsWith(name)) {
               branch = ref;
               break;
            }
         }
         // search for the branch in remote heads
         if (branch == null) {
            for (RefModel ref : JGitUtils.getRemoteBranches(repository, false, -1)) {
               if (ref.displayName.endsWith(name)) {
                  branch = ref;
                  break;
               }
            }
         }
      } catch (Throwable t) {
         LOGGER.error(MessageFormat.format("Failed to find {0} branch!", name), t);
      }
      return branch;
   }
   /**
    * 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.