本文整理汇总了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;
}
示例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());
}
示例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();
}
示例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);
}
示例5: parseCommit
import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
/**
* Parse commit
*
* @param id
* @return commit
*/
public RevCommit parseCommit(ObjectId id) {
return CommitUtils.getCommit(repository, id);
}
示例6: getCommit
import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
/** 저장소에서 커밋을 갖고 옴
* @param refName
* @return
*/
private RevCommit getCommit(String refName) {
return CommitUtils.getCommit(this.localRepo, refName);
}
示例7: getVCCommit
import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
/** 저장소에서 커밋을 갖고 옴
* @param refName
* @return
*/
public VCSimpleLog getVCCommit(String refName) {
return new VCSimpleLog(CommitUtils.getCommit(this.localRepo, refName));
}
示例8: getCommit
import org.gitective.core.CommitUtils; //导入方法依赖的package包/类
/** 저장소에서 커밋을 갖고 옴
* @param refName
* @return
*/
public RevCommit getCommit(String refName) {
return CommitUtils.getCommit(this.localRepo, refName);
}