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


Java CommitUtils类代码示例

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


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

示例1: getGitFileInfoList

import org.gitective.core.CommitUtils; //导入依赖的package包/类
/** 저장소의 파일 정보들을 가져와 파일 브라우져를 보여줄 때 사용.
 * @param commitID
 * @param filePath
 * @return
 */
public List<VCSimpleFileInfo> getGitFileInfoList(String commitID,String filePath) {
	List<VCSimpleFileInfo> gitFileInfoList = new ArrayList<VCSimpleFileInfo>();
	List<String> fileList = this.getGitFileList(commitID);
	try{			
		for(String path: WebUtil.getFileList(fileList, "/"+filePath)){
			RevCommit revCommit = CommitUtils.getLastCommit(this.localRepo,
					commitID, path.substring(1));
			String[] strArray = path.substring(1).split("/");
			VCSimpleFileInfo gitFileInfo = new VCSimpleFileInfo(
					strArray[strArray.length-1], path.substring(1),
					isDirectory(commitID,path.substring(1)),
					revCommit.getName(), revCommit.getShortMessage(),
					revCommit.getCommitTime(),
					revCommit.getCommitterIdent().getName(),
					revCommit.getCommitterIdent().getEmailAddress());
			gitFileInfoList.add(gitFileInfo);
		}

	}catch(Exception e){}
	return gitFileInfoList;
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:27,代码来源:GitUtil.java

示例2: 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

示例3: getNote

import org.gitective.core.CommitUtils; //导入依赖的package包/类
/**  커밋에 붙어있는 GIT 노트를 가져옴
 * @param commit
 * @return
 */
public String getNote(String commit){
	String str = new String();
	try{
		Note note = git.notesShow().setObjectId(CommitUtils.getCommit(git.getRepository(), commit)).call();
		ObjectLoader loader = this.localRepo.open(note.getData());
		str = new String(loader.getBytes());
	}finally{
		return str;
	}
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:15,代码来源:GitUtil.java

示例4: defaultObjectId

import org.gitective.core.CommitUtils; //导入依赖的package包/类
protected String defaultObjectId(Git git, String objectId) {
    if (objectId == null || objectId.trim().length() == 0) {
        RevCommit commit = CommitUtils.getHead(git.getRepository());
        objectId = commit.getName();
    }
    return objectId;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:8,代码来源:RepositoryResource.java

示例5: 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

示例6: 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

示例7: 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

示例8: getHEAD

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

示例9: getProjectVersion

import org.gitective.core.CommitUtils; //导入依赖的package包/类
public String getProjectVersion(File repoDir) throws IOException, GitAPIException {
	Git git = Git.open(repoDir);
	Repository repo = git.getRepository();
	
	// Find base commit between current branch and "master":
	String branch = repo.getBranch();
	RevCommit base = CommitUtils.getBase(repo, "master", branch);
	CommitCountFilter count = new CommitCountFilter();
	CommitFinder finder = new CommitFinder(repo).setFilter(count);
	finder.findBetween(branch, base);
	long commitsSinceBase = count.getCount();
	
	// Find tags in "master" before base commit:
	RevWalk rw = new RevWalk(repo);
	rw.markStart(base);
	rw.setRetainBody(false);
	Ref master = repo.getRef("master");
	List<Ref> masterAsList = Arrays.asList(master);
	List<Ref> tags = git.tagList().call();
	Map<RevCommit, Ref> masterTags = new HashMap<RevCommit, Ref>();
	for (Ref tag : tags) {
		tag = repo.peel(tag);
		ObjectId commitID = tag.getPeeledObjectId();
		if (commitID == null) continue;
		RevCommit commit = rw.parseCommit(commitID);
		// Only remember tags reachable from "master":
		if (!RevWalkUtils.findBranchesReachableFrom(commit, rw, masterAsList).isEmpty()) {
			masterTags.put(commit, tag);
		}
	}
	
	// Find the shortest distance in commits between base tag in "master":
	long commitsBetweenBaseAndTag = Long.MAX_VALUE;
	String tagName = "";
	for (RevCommit tagCommit : masterTags.keySet()) {
		count.reset();
		finder.findBetween(base, tagCommit);
		if (count.getCount() < commitsBetweenBaseAndTag) {
			commitsBetweenBaseAndTag = count.getCount();
			tagName = masterTags.get(tagCommit).getName();
		}
	}
	if (commitsBetweenBaseAndTag == Long.MAX_VALUE) {
		// If no tag, get total number of commits:
		commitsBetweenBaseAndTag = repo.getRefDatabase().getRefs("").size();
	}
	long commitsSinceLastMasterTag = commitsSinceBase + commitsBetweenBaseAndTag;
	
	// Construct version string:
	String version = branch.equals("master") ? "" : (branch + "-");
	if (tagName.startsWith("refs/tags/")) {
		tagName = tagName.substring("refs/tags/".length());
	}
	// v1.1 -> 1.1
	if (tagName.matches("v\\d+.*")) {
		tagName = tagName.substring(1);
	}
	if (tagName.isEmpty()) {
		version = "0";
	}
	version += tagName + ((!tagonly) ? "." + commitsSinceLastMasterTag : "");
	
	return version;
}
 
开发者ID:Hunternif,项目名称:JGitVersion,代码行数:65,代码来源:JGitVersionTask.java

示例10: 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

示例11: 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

示例12: 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

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