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


Java CommitUtils.getCommit方法代码示例

本文整理汇总了Java中org.gitective.core.CommitUtils.getCommit方法的典型用法代码示例。如果您正苦于以下问题:Java CommitUtils.getCommit方法的具体用法?Java CommitUtils.getCommit怎么用?Java CommitUtils.getCommit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.gitective.core.CommitUtils的用法示例。


在下文中一共展示了CommitUtils.getCommit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBlame

import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
/** git blame기능을 구현함.
 * @param filePath
 * @param commitID
 * @return
 */
public List<VCBlame> getBlame(String filePath, String commitID){
	List<VCBlame> gitBlames = new ArrayList<VCBlame>();
	RevCommit commit = CommitUtils.getCommit(this.localRepo, commitID);

	try{
		BlameResult result = git.blame().setStartCommit(commit).setFilePath(filePath).call();
		// 입력 받은 커밋을 기점으로 파일의 라인 별로 코드를 분석함.
		for(int i=0; i<result.getResultContents().size(); i++)
			gitBlames.add(new VCBlame(result.getSourceCommit(i)));

	}catch(Exception e){
		System.err.println(e.getMessage());
	}
	return gitBlames;
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:21,代码来源:GitUtil.java

示例2: walkFilesInCommit

import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
private void walkFilesInCommit(
    Git gitClient,
    RevCommit commit,
    List<SourceCodeFileAnalyzerPlugin> analyzers,
    MetricsProcessor metricsProcessor)
    throws IOException {
  commit = CommitUtils.getCommit(gitClient.getRepository(), commit.getId());
  logger.info("starting analysis of commit {}", commit.getName());
  DiffFormatter diffFormatter = new DiffFormatter(DisabledOutputStream.INSTANCE);
  diffFormatter.setRepository(gitClient.getRepository());
  diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);
  diffFormatter.setDetectRenames(true);

  ObjectId parentId = null;
  if (commit.getParentCount() > 0) {
    // TODO: support multiple parents
    parentId = commit.getParent(0).getId();
  }

  List<DiffEntry> diffs = diffFormatter.scan(parentId, commit);
  for (DiffEntry diff : diffs) {
    String filePath = diff.getPath(DiffEntry.Side.NEW);
    byte[] fileContent =
        BlobUtils.getRawContent(gitClient.getRepository(), commit.getId(), filePath);
    FileMetrics metrics = fileAnalyzer.analyzeFile(analyzers, filePath, fileContent);
    FileMetricsWithChangeType metricsWithChangeType =
        new FileMetricsWithChangeType(
            metrics, changeTypeMapper.jgitToCoderadar(diff.getChangeType()));
    metricsProcessor.processMetrics(metricsWithChangeType, gitClient, commit.getId(), filePath);
  }
  metricsProcessor.onCommitFinished(gitClient, commit.getId());
}
 
开发者ID:reflectoring,项目名称:coderadar,代码行数:33,代码来源:AnalyzingCommitProcessor.java

示例3: doDiff

import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
protected String doDiff(Git git, String objectId, String baseObjectId, String pathOrBlobPath) throws IOException {
    Repository r = git.getRepository();
    String blobPath = trimLeadingSlash(pathOrBlobPath);

    RevCommit commit;
    if (Strings.isNotBlank(objectId)) {
        commit = CommitUtils.getCommit(r, objectId);
    } else {
        commit = CommitUtils.getHead(r);
    }
    RevCommit baseCommit = null;
    if (Strings.isNotBlank(baseObjectId) && !Objects.equals(baseObjectId, objectId)) {
        baseCommit = CommitUtils.getCommit(r, baseObjectId);
    }

    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    DiffFormatter formatter = createDiffFormatter(r, buffer);

    RevTree commitTree = commit.getTree();
    RevTree baseTree;
    if (baseCommit == null) {
        if (commit.getParentCount() > 0) {
            final RevWalk rw = new RevWalk(r);
            RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
            rw.dispose();
            baseTree = parent.getTree();
        } else {
            // FIXME initial commit. no parent?!
            baseTree = commitTree;
        }
    } else {
        baseTree = baseCommit.getTree();
    }

    List<DiffEntry> diffEntries = formatter.scan(baseTree, commitTree);
    if (blobPath != null && blobPath.length() > 0) {
        for (DiffEntry diffEntry : diffEntries) {
            if (diffEntry.getNewPath().equalsIgnoreCase(blobPath)) {
                formatter.format(diffEntry);
                break;
            }
        }
    } else {
        formatter.format(diffEntries);
    }
    formatter.flush();
    return buffer.toString();
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:49,代码来源:RepositoryResource.java

示例4: doGetCommit

import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
protected static RevCommit doGetCommit(Git git, String commitId) {
    Repository repository = git.getRepository();
    return CommitUtils.getCommit(repository, commitId);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:5,代码来源:RepositoryResource.java

示例5: parseCommit

import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
/**
 * Parse commit
 *
 * @param id
 * @return commit
 */
public RevCommit parseCommit(ObjectId id) {
	return CommitUtils.getCommit(repository, id);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:10,代码来源:GitInfo.java

示例6: getCommit

import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
/** 저장소에서 커밋을 갖고 옴
 * @param refName
 * @return
 */
private RevCommit getCommit(String refName) {
	return CommitUtils.getCommit(this.localRepo, refName);
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:8,代码来源:GitUtil.java

示例7: getVCCommit

import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
/** 저장소에서 커밋을 갖고 옴
 * @param refName
 * @return
 */
public VCSimpleLog getVCCommit(String refName) {
	return new VCSimpleLog(CommitUtils.getCommit(this.localRepo, refName));
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:8,代码来源:GitUtil.java

示例8: getCommit

import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
/** 저장소에서 커밋을 갖고 옴
 * @param refName
 * @return
 */
public RevCommit getCommit(String refName) {
	return CommitUtils.getCommit(this.localRepo, refName);
}
 
开发者ID:LandvibeDev,项目名称:codefolio,代码行数:8,代码来源:GitUtils.java


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