本文整理汇总了Java中org.eclipse.jgit.api.LogCommand.call方法的典型用法代码示例。如果您正苦于以下问题:Java LogCommand.call方法的具体用法?Java LogCommand.call怎么用?Java LogCommand.call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.api.LogCommand
的用法示例。
在下文中一共展示了LogCommand.call方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillLastModifiedCommits
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
private void fillLastModifiedCommits(ObjectId start, String basePath) throws IOException, GitAPIException {
Map<String, ObjectId> objects = lastModifiedCommits.get(start);
if (objects == null) {
objects = new TreeMap<>();
}
DiffFormatter diffFmt = new DiffFormatter(NullOutputStream.INSTANCE);
diffFmt.setRepository(getGitRepository());
LogCommand log = new Git(getGitRepository()).log();
if (!basePath.isEmpty()) {
log.addPath(basePath);
}
for(RevCommit c: log.call()) {
final RevTree a = c.getParentCount() > 0 ? c.getParent(0).getTree() : null;
final RevTree b = c.getTree();
for(DiffEntry diff: diffFmt.scan(a, b)) {
objects.put(diff.getNewPath(), c.getId());
}
}
lastModifiedCommits.put(start, objects);
}
示例2: getCommiters
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
@Override
public List<GitUser> getCommiters() throws GitException {
List<GitUser> gitUsers = new ArrayList<>();
try {
LogCommand logCommand = getGit().log();
for (RevCommit commit : logCommand.call()) {
PersonIdent committerIdentity = commit.getCommitterIdent();
GitUser gitUser =
newDto(GitUser.class)
.withName(committerIdentity.getName())
.withEmail(committerIdentity.getEmailAddress());
if (!gitUsers.contains(gitUser)) {
gitUsers.add(gitUser);
}
}
} catch (GitAPIException exception) {
throw new GitException(exception.getMessage(), exception);
}
return gitUsers;
}
示例3: getHistoryFromLogCommand
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
private List<Revision> getHistoryFromLogCommand(final LogCommand command) throws StoreException {
final List<Revision> versions = Lists.newArrayList();
final Iterable<RevCommit> commits;
try {
commits = command.call();
} catch (GitAPIException e) {
throw new StoreException("Could not get history", e);
}
for( RevCommit commit : commits) {
versions.add(new Revision(
commit.getName(),
commit.getAuthorIdent().toExternalString(),
new Date(Long.valueOf(commit.getCommitTime()) * 1000 /* convert seconds to milliseconds */),
commit.getFullMessage()
));
}
return versions;
}
示例4: main
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
try (Git git = new Git(repository)) {
List<Ref> call = git.tagList().call();
for (Ref ref : call) {
System.out.println("Tag: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName());
// fetch all commits for this tag
LogCommand log = git.log();
Ref peeledRef = repository.peel(ref);
if(peeledRef.getPeeledObjectId() != null) {
log.add(peeledRef.getPeeledObjectId());
} else {
log.add(ref.getObjectId());
}
Iterable<RevCommit> logs = log.call();
for (RevCommit rev : logs) {
System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */);
}
}
}
}
}
示例5: fixCommitCount
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
private static TagVersionAndCount fixCommitCount(TagVersionAndCount resolved, Repository repo) throws RefNotFoundException, GitAPIException {
Git git = new Git(repo);
ObjectId target, head;
LogCommand logCommand;
try {
target = repo.getRef(resolved.getVersion()).getPeeledObjectId();
logCommand = git.log();
logCommand.add(target);
} catch (IOException e) {
throw new SemverGitflowPlugin.VersionApplicationException(e);
}
int count = 0;
for (RevCommit commit : logCommand.call()) {
count ++;
}
return new TagVersionAndCount(resolved.getVersion(), count);
}
示例6: buildWalk
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
private RevWalk buildWalk() throws GitAPIException, IncorrectObjectTypeException, MissingObjectException {
if (ref != null) {
final LogCommand logCommand = git._log().add(ref.getObjectId());
if (path != null && !path.isEmpty()) {
logCommand.addPath(path);
}
return (RevWalk) logCommand.call();
}
return new RevWalk(git.getRepository());
}
示例7: log
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
/**
* git log ref1
*/
public List<CommitInfo> log(RepositoryPK repositoryPK, String ref, Integer num) {
try (RepositoryReader reader = new RepositoryReader(repositoryPK)) {
Git git = reader.getGit();
Repository repository = reader.getRepository();
ObjectId objectId = repository.resolve(ref);
LogCommand command = git.log();
if (objectId != null) {
command.add(objectId);
}
if (num != null) {
command.setMaxCount(num);
}
Iterable<RevCommit> commits = command.call();
List<CommitInfo> commitInfos = new ArrayList<>();
for (RevCommit commit : commits) {
commitInfos.add(new CommitInfo(commit));
}
return commitInfos;
} catch (IOException | GitAPIException e) {
throw new RuntimeException(e);
}
}
示例8: resolveFirstCommitForTag
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
private RevCommit resolveFirstCommitForTag (Git git, Ref tagRef) throws IOException, GitAPIException {
LogCommand log = git.log();
Ref peeledRef = git.getRepository().peel(tagRef);
if(peeledRef.getPeeledObjectId() != null) {
log.add(peeledRef.getPeeledObjectId());
} else {
log.add(tagRef.getObjectId());
}
Iterable<RevCommit> logs = log.call();
return logs.iterator().next();
}
示例9: call
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
public List<String[]> call(final GitInfoStep gitInfoStep, Git git,
CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
throws InvalidRemoteException, TransportException, GitAPIException,
IllegalArgumentException, IOException {
final RevWalk walk = new RevWalk(git.getRepository());
LogCommand lc = git.log();
if (!Const.isEmpty(this.path)) {
lc = lc.addPath(gitInfoStep.environmentSubstitute(this.path));
}
if (this.maxCount != null) {
lc = lc.setMaxCount(Integer.parseInt(gitInfoStep
.environmentSubstitute(this.maxCount)));
}
if (this.skip != null) {
lc = lc.setSkip(Integer.parseInt(gitInfoStep
.environmentSubstitute(this.skip)));
}
final Iterable<RevCommit> logs = lc.call();
final Iterator<RevCommit> i = logs.iterator();
final List<String[]> commits = new ArrayList<String[]>();
while (i.hasNext()) {
final String[] commitRow = new String[] {null, null, null, null,
null, null, null, null, null, null};
final RevCommit commit = walk.parseCommit(i.next());
commitRow[0] = commit.getId().getName();
commitRow[1] = commit.getName();
commitRow[2] = commit.getFullMessage();
commitRow[3] = commit.getShortMessage();
commitRow[4] = dt.format(commit.getAuthorIdent().getWhen());
commitRow[5] = commit.getAuthorIdent().getName();
commitRow[6] = commit.getAuthorIdent().getEmailAddress();
commitRow[7] = dt.format(commit.getCommitterIdent().getWhen());
commitRow[8] = commit.getCommitterIdent().getName();
commitRow[9] = commit.getCommitterIdent().getEmailAddress();
commits.add(commitRow);
}
return commits;
}
示例10: findCommits
import org.eclipse.jgit.api.LogCommand; //导入方法依赖的package包/类
List<GitCommit> findCommits() throws IOException {
Repository repository = getRepository();
List<GitCommit> result = new LinkedList<>();
ObjectId head = repository.resolve("HEAD");
logger.debug("Found head: {}", head);
RevWalk rw = new RevWalk(repository);
try (Git git = new Git(repository)) {
LogCommand logCommand = getLogWithOrWithOutRange(git, range);
Iterable<RevCommit> commits = logCommand.call();
DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
df.setRepository(repository);
df.setDiffComparator(RawTextComparator.DEFAULT);
df.setDetectRenames(true);
for (RevCommit commit : commits) {
logger.debug("Commit-Message: '{}'", commit.getShortMessage());
final Date date = new Date(1000 * (long) commit.getCommitTime());
final GitCommit gitCommit = retrieveCommit(ObjectId.toString(commit.getId()));
gitCommit.setAuthor(makeStringOfIdent(commit.getAuthorIdent()));
gitCommit.setCommitter(makeStringOfIdent(commit.getCommitterIdent()));
gitCommit.setDate(date);
gitCommit.setMessage(commit.getFullMessage());
gitCommit.setShortMessage(commit.getShortMessage());
gitCommit.setEncoding(commit.getEncodingName());
addCommitParents(rw, df, commit, gitCommit);
result.add(gitCommit);
}
} catch (GitAPIException e) {
throw new IllegalStateException("Could not read logs from Git repository '" + path + "'", e);
} finally {
rw.close();
repository.close();
}
logger.debug("Found #{} commits", result.size());
return result;
}