本文整理匯總了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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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();
}
}
示例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());
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
};
}
示例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));
}
}