本文整理汇总了Java中org.eclipse.jgit.util.RawParseUtils.commitMessage方法的典型用法代码示例。如果您正苦于以下问题:Java RawParseUtils.commitMessage方法的具体用法?Java RawParseUtils.commitMessage怎么用?Java RawParseUtils.commitMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.util.RawParseUtils
的用法示例。
在下文中一共展示了RawParseUtils.commitMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFooterLines
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
/**
* Parse the footer lines (e.g. "Signed-off-by") for machine processing.
* <p>
* This method splits all of the footer lines out of the last paragraph of
* the commit message, providing each line as a key-value pair, ordered by
* the order of the line's appearance in the commit message itself.
* <p>
* A footer line's key must match the pattern {@code ^[A-Za-z0-9-]+:}, while
* the value is free-form, but must not contain an LF. Very common keys seen
* in the wild are:
* <ul>
* <li>{@code Signed-off-by} (agrees to Developer Certificate of Origin)
* <li>{@code Acked-by} (thinks change looks sane in context)
* <li>{@code Reported-by} (originally found the issue this change fixes)
* <li>{@code Tested-by} (validated change fixes the issue for them)
* <li>{@code CC}, {@code Cc} (copy on all email related to this change)
* <li>{@code Bug} (link to project's bug tracking system)
* </ul>
*
* @return ordered list of footer lines; empty list if no footers found.
*/
public final List<FooterLine> getFooterLines() {
final byte[] raw = buffer;
int ptr = raw.length - 1;
while (raw[ptr] == '\n') // trim any trailing LFs, not interesting
ptr--;
final int msgB = RawParseUtils.commitMessage(raw, 0);
final ArrayList<FooterLine> r = new ArrayList<>(4);
final Charset enc = guessEncoding();
for (;;) {
ptr = RawParseUtils.prevLF(raw, ptr);
if (ptr <= msgB)
break; // Don't parse commit headers as footer lines.
final int keyStart = ptr + 2;
if (raw[keyStart] == '\n')
break; // Stop at first paragraph break, no footers above it.
final int keyEnd = RawParseUtils.endOfFooterLineKey(raw, keyStart);
if (keyEnd < 0)
continue; // Not a well formed footer line, skip it.
// Skip over the ': *' at the end of the key before the value.
//
int valStart = keyEnd + 1;
while (valStart < raw.length && raw[valStart] == ' ')
valStart++;
// Value ends at the LF, and does not include it.
//
int valEnd = RawParseUtils.nextLF(raw, valStart);
if (raw[valEnd - 1] == '\n')
valEnd--;
r.add(new FooterLine(raw, enc, keyStart, keyEnd, valStart, valEnd));
}
Collections.reverse(r);
return r;
}
示例2: textFor
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
static RawCharSequence textFor(final RevCommit cmit) {
final byte[] raw = cmit.getRawBuffer();
final int b = RawParseUtils.commitMessage(raw, 0);
if (b < 0)
return RawCharSequence.EMPTY;
return new RawCharSequence(raw, b, raw.length);
}
示例3: parseChangeMessage
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
private void parseChangeMessage(
PatchSet.Id psId,
Account.Id accountId,
Account.Id realAccountId,
ChangeNotesCommit commit,
Timestamp ts) {
byte[] raw = commit.getRawBuffer();
int size = raw.length;
Charset enc = RawParseUtils.parseEncoding(raw);
int subjectStart = RawParseUtils.commitMessage(raw, 0);
if (subjectStart < 0 || subjectStart >= size) {
return;
}
int subjectEnd = RawParseUtils.endOfParagraph(raw, subjectStart);
if (subjectEnd == size) {
return;
}
int changeMessageStart;
if (raw[subjectEnd] == '\n') {
changeMessageStart = subjectEnd + 2; // \n\n ends paragraph
} else if (raw[subjectEnd] == '\r') {
changeMessageStart = subjectEnd + 4; // \r\n\r\n ends paragraph
} else {
return;
}
int ptr = size - 1;
int changeMessageEnd = -1;
while (ptr > changeMessageStart) {
ptr = RawParseUtils.prevLF(raw, ptr, '\r');
if (ptr == -1) {
break;
}
if (raw[ptr] == '\n') {
changeMessageEnd = ptr - 1;
break;
} else if (raw[ptr] == '\r') {
changeMessageEnd = ptr - 3;
break;
}
}
if (ptr <= changeMessageStart) {
return;
}
String changeMsgString =
RawParseUtils.decode(enc, raw, changeMessageStart, changeMessageEnd + 1);
ChangeMessage changeMessage =
new ChangeMessage(
new ChangeMessage.Key(psId.getParentKey(), commit.name()), accountId, ts, psId);
changeMessage.setMessage(changeMsgString);
changeMessage.setTag(tag);
changeMessage.setRealAuthor(realAccountId);
changeMessagesByPatchSet.put(psId, changeMessage);
allChangeMessages.add(changeMessage);
}
示例4: getFullMessage
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
/**
* Parse the complete commit message and decode it to a string.
* <p>
* This method parses and returns the message portion of the commit buffer,
* after taking the commit's character set into user and decoding the
* buffer using that character set. This method is a fairly expensive
* operation and produces a new string on each invocation.
*
* @return decoded commit message as a string. Never null.
*/
public final String getFullMessage() {
byte[] raw = buffer;
int msgB = RawParseUtils.commitMessage(raw, 0);
if (msgB < 0) {
return ""; //$NON-NLS-1$
}
return RawParseUtils.decode(guessEncoding(), raw, msgB, raw.length);
}
示例5: getShortMessage
import org.eclipse.jgit.util.RawParseUtils; //导入方法依赖的package包/类
/**
* Parse the commit message and return the first "line" of it.
* <p>
* The first line is everything up to the first pair of LFs. This is the
* "oneline" format, suitable for output in a single line display.
* <p>
* This method parses and returns the message portion of the commit buffer,
* after taking the commit's character set into user and decoding the
* buffer using that character set. This method is a fairly expensive
* operation and produces a new string on each invocation.
*
* @return decoded commit message as a string. Never null. The returned
* string does not contain any LFs, even if the first paragraph
* spanned multiple lines. Embedded LFs are converted to spaces.
*/
public final String getShortMessage() {
byte[] raw = buffer;
int msgB = RawParseUtils.commitMessage(raw, 0);
if (msgB < 0) {
return ""; //$NON-NLS-1$
}
int msgE = RawParseUtils.endOfParagraph(raw, msgB);
String str = RawParseUtils.decode(guessEncoding(), raw, msgB, msgE);
if (hasLF(raw, msgB, msgE)) {
str = StringUtils.replaceLineBreaksWithSpace(str);
}
return str;
}