本文整理汇总了Java中org.eclipse.jgit.revwalk.RevCommit.getCommitterIdent方法的典型用法代码示例。如果您正苦于以下问题:Java RevCommit.getCommitterIdent方法的具体用法?Java RevCommit.getCommitterIdent怎么用?Java RevCommit.getCommitterIdent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.revwalk.RevCommit
的用法示例。
在下文中一共展示了RevCommit.getCommitterIdent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: getRepoMetadata
import org.eclipse.jgit.revwalk.RevCommit; //导入方法依赖的package包/类
/**
* Fetch all commit metadata from the repo
* @param repoDir repository directory
* @return list of commit metadata
* @throws IOException
* @throws GitAPIException
*/
public static List<CommitMetadata> getRepoMetadata(String repoDir) throws IOException, GitAPIException {
List<CommitMetadata> metadataList = new ArrayList<>();
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File(repoDir, ".git")).readEnvironment().findGitDir().build();
// Current branch may not be master. Instead of hard coding determine the current branch
String currentBranch = repository.getBranch();
Ref head = repository.getRef("refs/heads/" + currentBranch); // current branch may not be "master"
if (head == null) {
return metadataList;
}
Git git = new Git(repository);
RevWalk walk = new RevWalk(repository);
RevCommit commit = walk.parseCommit(head.getObjectId());
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(commit.getTree());
treeWalk.setRecursive(true);
while (treeWalk.next()) {
String filePath = treeWalk.getPathString();
Iterable<RevCommit> commitLog = git.log().add(repository.resolve(Constants.HEAD)).addPath(filePath).call();
for (RevCommit r : commitLog) {
CommitMetadata metadata = new CommitMetadata(r.getName());
metadata.setFilePath(filePath);
metadata.setFileName(FilenameUtils.getName(filePath));
metadata.setMessage(r.getShortMessage().trim());
// Difference between committer and author
// refer to: http://git-scm.com/book/ch2-3.html
PersonIdent committer = r.getCommitterIdent();
PersonIdent author = r.getAuthorIdent();
metadata.setAuthor(author.getName());
metadata.setAuthorEmail(author.getEmailAddress());
metadata.setCommitter(committer.getName());
metadata.setCommitterEmail(committer.getEmailAddress());
metadata.setCommitTime(committer.getWhen());
metadataList.add(metadata);
}
}
git.close();
return metadataList;
}