@Override
public VcsLogInfo parse(String script, String s) {
List<VcsLogInfo.LogEntry> entries = new ArrayList<VcsLogInfo.LogEntry>();
OpenStringBuilder comment = new OpenStringBuilder(256);
for (PeekingIterator<String> it = peekingIterator(Splitter.on("\n").trimResults().split(s).iterator()); it.hasNext(); ) {
String line;
String revision = null;
for(line = it.next();it.hasNext();line=it.next()){
if(line.startsWith("commit")) {
revision = substringAfter(line, " ").trim();
Matcher matcher = HASH_REGEX.matcher(revision);
if(matcher.matches()){
break;
}
}
}
if(revision == null) break;
while(it.hasNext() && !it.peek().contains("Author: ")) it.next();
String author = substringAfter(it.next(), "Author: ");
String stringDate = substringAfter(it.next(), "Date: ").trim();
DateTime date = DateTime.parse(stringDate, GIT_DATE_FORMAT);
it.next(); //empty line
comment.setLength(0);
while (it.hasNext()) {
line = it.peek();
String possibleRevision = substringAfter(line, " ");
if (HASH_REGEX.matcher(possibleRevision).matches()) {
break;
}
comment.append(it.next()).append("\n");
}
comment.trim();
entries.add(new VcsLogInfo.LogEntry(date, author, comment.toString(), revision));
}
return new VcsLogInfo(s, entries);
}