本文整理汇总了Java中com.gitblit.models.AnnotatedLine类的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedLine类的具体用法?Java AnnotatedLine怎么用?Java AnnotatedLine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotatedLine类属于com.gitblit.models包,在下文中一共展示了AnnotatedLine类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: blame
import com.gitblit.models.AnnotatedLine; //导入依赖的package包/类
/**
* Returns the list of lines in the specified source file annotated with the source commit metadata.
*
* @param repository
* @param blobPath
* @param objectId
* @return list of annotated lines
*/
public static List<AnnotatedLine> blame(Repository repository, String blobPath, String objectId) {
List<AnnotatedLine> lines = new ArrayList<AnnotatedLine>();
try {
ObjectId object;
if (StringUtils.isEmpty(objectId)) {
object = JGitUtils.getDefaultBranch(repository);
} else {
object = repository.resolve(objectId);
}
BlameCommand blameCommand = new BlameCommand(repository);
blameCommand.setFilePath(blobPath);
blameCommand.setStartCommit(object);
BlameResult blameResult = blameCommand.call();
RawText rawText = blameResult.getResultContents();
int length = rawText.size();
for (int i = 0; i < length; i++) {
RevCommit commit = blameResult.getSourceCommit(i);
AnnotatedLine line = new AnnotatedLine(commit, i + 1, rawText.getString(i));
lines.add(line);
}
} catch (Throwable t) {
LOGGER.error(MessageFormat.format("failed to generate blame for {0} {1}!", blobPath, objectId), t);
}
return lines;
}
示例2: blame
import com.gitblit.models.AnnotatedLine; //导入依赖的package包/类
/**
* Returns the list of lines in the specified source file annotated with the
* source commit metadata.
*
* @param repository
* @param blobPath
* @param objectId
* @return list of annotated lines
*/
public static List<AnnotatedLine> blame(Repository repository, String blobPath, String objectId) {
List<AnnotatedLine> lines = new ArrayList<AnnotatedLine>();
try {
ObjectId object;
if (StringUtils.isEmpty(objectId)) {
object = JGitUtils.getDefaultBranch(repository);
} else {
object = repository.resolve(objectId);
}
BlameCommand blameCommand = new BlameCommand(repository);
blameCommand.setFilePath(blobPath);
blameCommand.setStartCommit(object);
BlameResult blameResult = blameCommand.call();
RawText rawText = blameResult.getResultContents();
int length = rawText.size();
for (int i = 0; i < length; i++) {
RevCommit commit = blameResult.getSourceCommit(i);
AnnotatedLine line = new AnnotatedLine(commit, i + 1, rawText.getString(i));
lines.add(line);
}
} catch (Throwable t) {
LOGGER.error(MessageFormat.format("failed to generate blame for {0} {1}!", blobPath, objectId), t);
}
return lines;
}
示例3: testBlame
import com.gitblit.models.AnnotatedLine; //导入依赖的package包/类
@Test
public void testBlame() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
List<AnnotatedLine> lines = DiffUtils.blame(repository, "java.java",
"1d0c2933a4ae69c362f76797d42d6bd182d05176");
repository.close();
assertTrue(lines.size() > 0);
assertEquals("c6d31dccf5cc75e8e46299fc62d38f60ec6d41e0", lines.get(0).commitId);
}