当前位置: 首页>>代码示例>>Java>>正文


Java AnnotatedLine类代码示例

本文整理汇总了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;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:34,代码来源:DiffUtils.java

示例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;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:35,代码来源:DiffUtils.java

示例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);
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:10,代码来源:DiffUtilsTest.java


注:本文中的com.gitblit.models.AnnotatedLine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。