James Moger
2014-03-27 ab07d0d86d8b64b4f7c88b45bc81f1eec22105db
src/main/java/com/gitblit/git/PatchsetReceivePack.java
@@ -437,7 +437,10 @@
            patchsetRefCmd.setResult(Result.OK);
            // update the ticket branch ref
            RefUpdate ru = updateRef(patchsetCmd.getTicketBranch(), patchsetCmd.getNewId());
            RefUpdate ru = updateRef(
                  patchsetCmd.getTicketBranch(),
                  patchsetCmd.getNewId(),
                  patchsetCmd.getPatchsetType());
            updateReflog(ru);
            TicketModel ticket = processPatchset(patchsetCmd);
@@ -835,8 +838,8 @@
               psCmd.updateTicket(c, mergeTo, ticket, null);
               // create a ticket patchset ref
               updateRef(psCmd.getPatchsetBranch(), c.getId());
               RefUpdate ru = updateRef(psCmd.getTicketBranch(), c.getId());
               updateRef(psCmd.getPatchsetBranch(), c.getId(), patchset.type);
               RefUpdate ru = updateRef(psCmd.getTicketBranch(), c.getId(), patchset.type);
               updateReflog(ru);
               // create a change from the patchset command
@@ -897,11 +900,20 @@
      if (parseMessage) {
         // parse commit message looking for fixes/closes #n
         Pattern p = Pattern.compile("(?:fixes|closes)[\\s-]+#?(\\d+)", Pattern.CASE_INSENSITIVE);
         Matcher m = p.matcher(commit.getFullMessage());
         while (m.find()) {
            String val = m.group(1);
            return Long.parseLong(val);
         String dx = "(?:fixes|closes)[\\s-]+#?(\\d+)";
         String x = settings.getString(Keys.tickets.closeOnPushCommitMessageRegex, dx);
         if (StringUtils.isEmpty(x)) {
            x = dx;
         }
         try {
            Pattern p = Pattern.compile(x, Pattern.CASE_INSENSITIVE);
            Matcher m = p.matcher(commit.getFullMessage());
            while (m.find()) {
               String val = m.group(1);
               return Long.parseLong(val);
            }
         } catch (Exception e) {
            LOGGER.error(String.format("Failed to parse \"%s\" in commit %s", x, commit.getName()), e);
         }
      }
      return 0L;
@@ -1043,7 +1055,7 @@
      return newPatchset;
   }
   private RefUpdate updateRef(String ref, ObjectId newId) {
   private RefUpdate updateRef(String ref, ObjectId newId, PatchsetType type) {
      ObjectId ticketRefId = ObjectId.zeroId();
      try {
         ticketRefId = getRepository().resolve(ref);
@@ -1054,7 +1066,17 @@
      try {
         RefUpdate ru = getRepository().updateRef(ref,  false);
         ru.setRefLogIdent(getRefLogIdent());
         ru.setForceUpdate(true);
         switch (type) {
         case Amend:
         case Rebase:
         case Rebase_Squash:
         case Squash:
            ru.setForceUpdate(true);
            break;
         default:
            break;
         }
         ru.setExpectedOldObjectId(ticketRefId);
         ru.setNewObjectId(newId);
         RefUpdate.Result result = ru.update(getRevWalk());