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


Java RevCommit类代码示例

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


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

示例1: getCommitListCount

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
/** 커밋 갯수를 가져옴
 * @param refName
 * @return
 */
public int getCommitListCount(String refName) {
	try {
		Iterable<RevCommit> gitLogIterable = this.git
				.log()
				.add(
						this.getCommit(refName))
				.call();
		int length = 0;

		for (RevCommit revCommit : gitLogIterable) {
			length++;
		}
		return length;
	} catch (Exception e) {
		return 0;
	}

}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:23,代码来源:GitUtil.java

示例2: getGitFileInfoList

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的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

示例3: simpleFileBrowser

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
/** 단순하게 커밋을 트리워크를 이용하여 당시 파일 내역을 출력.
 * @param commit
 * @return
 */
private String simpleFileBrowser(RevCommit commit){
	String out = new String();
	try
	{
		TreeWalk treeWalk = new TreeWalk(this.localRepo);
		treeWalk.addTree(new RevWalk(this.localRepo).parseTree(	commit));

		while (treeWalk.next())
		{
			out+="--- /dev/null\n";
			out+="+++ b/"+treeWalk.getPathString()+"\n";
			out+= "+"+BlobUtils.getContent(this.localRepo, commit,treeWalk.getPathString().replace("\n", "\n+"));
			out+="\n";
		}
	}finally{
		return out;
	}
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:23,代码来源:GitUtil.java

示例4: getLogList

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
public List<VCSimpleLog> getLogList(String branchName,
		int page, int number) {
	List<VCSimpleLog> gitLogList = new ArrayList<VCSimpleLog>();
	int startNumber = number * (page - 1);
	try {

		for(RevCommit commit:git.log().add(
				this.getCommit(branchName)).setSkip(startNumber).setMaxCount(number).call()){

			VCSimpleLog gitLog = new VCSimpleLog(commit
					.getId().getName(), commit.getShortMessage(), commit
					.getCommitterIdent().getName(), commit
					.getCommitterIdent().getEmailAddress(),
					commit.getCommitTime());

			gitLogList.add(gitLog);
		}

	} finally {
		return gitLogList;
	}
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:23,代码来源:GitUtil.java

示例5: getRevCommit

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
@Nullable
public RevCommit getRevCommit(ObjectId revId, boolean mustExist) {
	if (commitCache == null)
		commitCache = new HashMap<>();
	RevCommit commit;
	Optional<RevCommit> optional = commitCache.get(revId);
	if (optional == null) {
		try (RevWalk revWalk = new RevWalk(getRepository())) {
			optional = Optional.fromNullable(GitUtils.parseCommit(revWalk, revId));
		}
		commitCache.put(revId, optional);
	}
	commit = optional.orNull();
	
	if (mustExist && commit == null)
		throw new ObjectNotFoundException("Unable to find commit associated with object id: " + revId);
	else
		return commit;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:20,代码来源:Project.java

示例6: getAuthorName

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
@Override
public String getAuthorName( String commitId ) {
  if ( commitId.equals( IVCS.WORKINGTREE ) ) {
    Config config = git.getRepository().getConfig();
    return config.get( UserConfig.KEY ).getAuthorName()
        + " <" + config.get( UserConfig.KEY ).getAuthorEmail() + ">";
  } else {
    RevCommit commit = resolve( commitId );
    PersonIdent author = commit.getAuthorIdent();
    final StringBuilder r = new StringBuilder();
    r.append( author.getName() );
    r.append( " <" ); //$NON-NLS-1$
    r.append( author.getEmailAddress() );
    r.append( ">" ); //$NON-NLS-1$
    return r.toString();
  }
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:18,代码来源:UIGit.java

示例7: should_list_commit_success

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
@Test
public void should_list_commit_success() throws Throwable {

    File folder = this.folder.newFolder("info");
    JGitUtil.clone(GIT_URL, folder.toPath());
    JGitUtil.fetchTags(folder.toPath(), ORIGIN);

    JGitUtil.checkout(folder.toPath(), "v1.1");

    // when: list commit
    List<RevCommit> commits = JGitUtil.listCommits(folder.toPath());

    // then: should equal commit id
    Assert.assertEquals(34, commits.size());

    // then: should equal latest commit id
    Assert.assertEquals("30b728df5bdd3c51f8e032e90542d5d19eecf0f3",
        JGitUtil.listCommits(folder.toPath()).get(0).getId().getName());
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:20,代码来源:JGitUtilTest.java

示例8: getCommits

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
/**
 * Get commits belonging to this update, reversely ordered by commit traversing. The list of commit will remain 
 * unchanged even if tip of target branch changes. This assumption is key to our caching of code comment to
 * to pull request relations. Check {@link DefaultCodeCommentRelationManager#findCodeComments(PullRequest)} for
 * details
 * 
 * @return
 * 			commits belonging to this update ordered by commit id
 */
public List<RevCommit> getCommits() {
	if (commits == null) {
		commits = new ArrayList<>();
		
		try (RevWalk revWalk = new RevWalk(getRequest().getWorkProject().getRepository())) {
			revWalk.markStart(revWalk.parseCommit(ObjectId.fromString(getHeadCommitHash())));
			revWalk.markUninteresting(revWalk.parseCommit(ObjectId.fromString(getBaseCommitHash())));
			
			/*
			 * Instead of excluding commits reachable from target branch, we exclude commits reachable
			 * from the merge commit to achieve two purposes:
			 * 1. commits merged back into target branch after this update can still be included in this
			 * update
			 * 2. commits of this update will remain unchanged even if tip of the target branch changes     
			 */
			revWalk.markUninteresting(revWalk.parseCommit(ObjectId.fromString(getMergeBaseCommitHash())));
			
			revWalk.forEach(c->commits.add(c));
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		Collections.reverse(commits);
	}
	return commits;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:35,代码来源:PullRequestUpdate.java

示例9: detectAtCommit

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
public void detectAtCommit(Repository repository, String commitId, StructuralDiffHandler handler) {
	File metadataFolder = repository.getDirectory();
	File projectFolder = metadataFolder.getParentFile();
	GitService gitService = new GitServiceImpl();
	//RevWalk walk = new RevWalk(repository);
	try (RevWalk walk = new RevWalk(repository)) {
		RevCommit commit = walk.parseCommit(repository.resolve(commitId));
		if (commit.getParentCount() == 1) {
		    walk.parseCommit(commit.getParent(0));
		    this.detectRefactorings(gitService, repository, handler, projectFolder, commit);
		}
	} catch (Exception e) {
	    logger.warn(String.format("Ignored revision %s due to error", commitId), e);
	    handler.handleException(commitId, e);
       }
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:17,代码来源:GitHistoryStructuralDiffAnalyzer.java

示例10: toCommit

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
private static Commit toCommit(RevCommit revCommit) {
    final Author author;
    final PersonIdent committerIdent = revCommit.getCommitterIdent();
    if (committerIdent == null) {
        author = Author.UNKNOWN;
    } else {
        author = new Author(committerIdent.getName(), committerIdent.getEmailAddress());
    }
    long when = committerIdent.getWhen().getTime();

    try {
        return CommitUtil.newCommit(author, when, revCommit.getFullMessage());
    } catch (Exception e) {
        throw new StorageException("failed to create a Commit", e);
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:17,代码来源:GitRepository.java

示例11: getChangedFiles

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
private Set<String> getChangedFiles(Project project, ObjectId oldObjectId, ObjectId newObjectId) {
	Set<String> changedFiles = new HashSet<>();
	try (TreeWalk treeWalk = new TreeWalk(project.getRepository())) {
		treeWalk.setFilter(TreeFilter.ANY_DIFF);
		treeWalk.setRecursive(true);
		RevCommit oldCommit = project.getRevCommit(oldObjectId);
		RevCommit newCommit = project.getRevCommit(newObjectId);
		treeWalk.addTree(oldCommit.getTree());
		treeWalk.addTree(newCommit.getTree());
		while (treeWalk.next()) {
			changedFiles.add(treeWalk.getPathString());
		}
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
	return changedFiles;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:18,代码来源:DefaultProjectManager.java

示例12: applyStashChangesLocally

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
private void applyStashChangesLocally(List<RevCommit> stashesToApply) throws GitAPIException {
    RevCommit tmpCommit = null;
    // We cannot just apply changes from stash one after the other
    // as git will complain about uncommitted changes when trying
    // to apply second consecutive stash.
    // So we create temporary commits to overcome this issue
    // and reset softly on the way to have it all as local changes
    for (final RevCommit stash : stashesToApply) {
        if (stash == null){
            continue;
        }
        git.stashApply().setStashRef(stash.getName()).call();
        if (tmpCommit != null) {
            git.reset().setRef(ONE_BACK).setMode(SOFT).call();
        }
        tmpCommit = createTemporaryCommit();
    }
    if (tmpCommit != null) {
        git.reset().setRef(ONE_BACK).setMode(SOFT).call();
    }
    git.stashDrop().setAll(true).call();
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:23,代码来源:ChangeApplier.java

示例13: respond

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
@Override
protected void respond(AjaxRequestTarget target) {
	IRequestParameters params = RequestCycle.get().getRequest().getPostParameters();
	
	String tooltipId = params.getParameterValue("tooltip").toString();
	String commitHash = params.getParameterValue("commit").toString();
	RevCommit commit = getProject().getRevCommit(commitHash);
	String authoring;
	if (commit.getAuthorIdent() != null) {
		authoring = commit.getAuthorIdent().getName();
		if (commit.getCommitterIdent() != null)
			authoring += " " + DateUtils.formatAge(commit.getCommitterIdent().getWhen());
		authoring = "'" + JavaScriptEscape.escapeJavaScript(authoring) + "'";
	} else {
		authoring = "undefined";
	}
	String message = JavaScriptEscape.escapeJavaScript(commit.getFullMessage());
	String script = String.format("gitplex.server.blameMessage.show('%s', %s, '%s');", tooltipId, authoring, message); 
	target.appendJavaScript(script);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:21,代码来源:BlameMessageBehavior.java

示例14: CommitListPanel

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
public CommitListPanel(String id, IModel<Project> projectModel, IModel<List<RevCommit>> commitsModel) {
	super(id);
	this.projectModel = projectModel;
	this.commitsModel = new LoadableDetachableModel<List<RevCommit>>() {

		@Override
		protected List<RevCommit> load() {
			List<RevCommit> commits = commitsModel.getObject();
			if (commits.size() > WebConstants.MAX_DISPLAY_COMMITS)
				commits = commits.subList(commits.size()-WebConstants.MAX_DISPLAY_COMMITS, commits.size());
			CommitGraphUtils.sort(commits, 0);
			return separateByDate(commits);
		}

		@Override
		protected void onDetach() {
			commitsModel.detach();
			super.onDetach();
		}
		
	};
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:23,代码来源:CommitListPanel.java

示例15: testMergeWithoutConflicts

import org.eclipse.jgit.revwalk.RevCommit; //导入依赖的package包/类
@Test
public void testMergeWithoutConflicts() throws Exception {
	addFileAndCommit("initial", "", "initial");
	git.checkout().setCreateBranch(true).setName("dev").call();
	addFileAndCommit("dev1", "", "dev1");
	addFileAndCommit("dev2", "", "dev2");
	git.checkout().setName("master").call();
	addFileAndCommit("master1", "", "master1");
	addFileAndCommit("master2", "", "master2");
	ObjectId masterId = git.getRepository().resolve("master");
	ObjectId devId = git.getRepository().resolve("dev");
	ObjectId mergeCommitId = GitUtils.merge(git.getRepository(), devId, masterId, false, user, "merge commit");
	try (	RevWalk revWalk = new RevWalk(git.getRepository());
			TreeWalk treeWalk = new TreeWalk(git.getRepository())) {
		RevCommit mergeCommit = revWalk.parseCommit(mergeCommitId);
		treeWalk.addTree(mergeCommit.getTree());
		Set<String> files = new HashSet<>();
		while (treeWalk.next()) {
			files.add(treeWalk.getPathString());
		}
		assertEquals(Sets.newHashSet("initial", "dev1", "dev2", "master1", "master2"), files);
		assertEquals(2, mergeCommit.getParentCount());
		assertEquals(masterId, mergeCommit.getParent(0));
		assertEquals(devId, mergeCommit.getParent(1));
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:27,代码来源:GitUtilsTest.java


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