示例#1
0
文件: Commit.java 项目: Jeebiss/spazz
 public List<String> format() {
   List<String> messages = new ArrayList<String>();
   String cm = message;
   Matcher ma = emojiPattern.matcher(cm);
   while (ma.find()) {
     if (Spazz.github.getEmojis().containsKey(ma.group(1).toLowerCase()))
       cm =
           cm.replaceFirst(
               ma.group(0),
               Utilities.getShortUrl(Spazz.github.getEmojis().get(ma.group(1).toLowerCase())));
   }
   String[] messageSplit = cm.replace("<", "<LT>").split("\n+");
   StringBuilder message =
       new StringBuilder("<D>  ")
           .append(author.getName())
           .append("<C>: ")
           .append(messageSplit[0])
           .append(" - ");
   boolean added = false;
   int m = 0;
   for (int i = 1; i < messageSplit.length; i++) {
     String msg = messageSplit[i];
     if (m < 3) {
       char last = msg.charAt(msg.length() - 1);
       if (last == '.' || last == '?' || last == '!') m = 3;
       else m++;
       if (i + 1 == messageSplit.length) {
         added = true;
         message.append(messageSplit[i]).append(" -- ").append(getShortUrl());
         messages.add(message.toString());
       } else message.append(messageSplit[i]).append(" ");
     } else {
       m = 1;
       messages.add(message.substring(0, message.length() - 1));
       if (i + 1 == messageSplit.length) {
         added = true;
         messages.add(messageSplit[i] + " -- " + getShortUrl());
       } else message = new StringBuilder(messageSplit[i]).append(" ");
     }
   }
   if (!added) messages.add(message.substring(0, message.length() - 3) + " -- " + getShortUrl());
   return messages;
 }
示例#2
0
文件: Commit.java 项目: Jeebiss/spazz
 public String getShortUrl() {
   return Utilities.getShortUrl(getUrl());
 }