Java Code Examples for org.eclipse.jgit.lib.PersonIdent#getName()

The following examples show how to use org.eclipse.jgit.lib.PersonIdent#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitRepository.java    From centraldogma with Apache License 2.0 6 votes vote down vote up
private static Commit toCommit(RevCommit revCommit) {
    final Author author;
    final PersonIdent committerIdent = revCommit.getCommitterIdent();
    final long when;
    if (committerIdent == null) {
        author = Author.UNKNOWN;
        when = 0;
    } else {
        author = new Author(committerIdent.getName(), committerIdent.getEmailAddress());
        when = committerIdent.getWhen().getTime();
    }

    try {
        return CommitUtil.newCommit(author, when, revCommit.getFullMessage());
    } catch (Exception e) {
        throw new StorageException("failed to create a Commit", e);
    }
}
 
Example 2
Source File: RepositoryResource.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
public CommitInfo createCommitInfo(RevCommit entry) {
    final Date date = GitUtils.getCommitDate(entry);
    PersonIdent authorIdent = entry.getAuthorIdent();
    String author = null;
    String name = null;
    String email = null;
    String avatarUrl = null;
    if (authorIdent != null) {
        author = authorIdent.getName();
        name = authorIdent.getName();
        email = authorIdent.getEmailAddress();

        // lets try default the avatar
        if (Strings.isNotBlank(email)) {
            avatarUrl = getAvatarUrl(email);
        }
    }
    boolean merge = entry.getParentCount() > 1;
    String shortMessage = entry.getShortMessage();
    String sha = entry.getName();
    return new CommitInfo(sha, author, name, email, avatarUrl, date, merge, shortMessage);
}
 
Example 3
Source File: GitSCM.java    From repositoryminer with Apache License 2.0 6 votes vote down vote up
private Commit processCommit(RevCommit revCommit) {
	PersonIdent author = revCommit.getAuthorIdent();
	PersonIdent committer = revCommit.getCommitterIdent();

	Developer myAuthor = new Developer(author.getName(), author.getEmailAddress());
	Developer myCommitter = new Developer(committer.getName(), committer.getEmailAddress());

	List<String> parents = new ArrayList<String>();
	for (RevCommit parent : revCommit.getParents()) {
		parents.add(parent.getName());
	}

	List<Change> changes = null;
	try {
		changes = getChangesForCommitedFiles(revCommit.getName());
	} catch (IOException e) {
		close();
		throw new RepositoryMinerException(e);
	}

	return new Commit(null, revCommit.getName(), myAuthor, myCommitter, revCommit.getFullMessage().trim(), changes,
			parents, author.getWhen(), committer.getWhen(), (parents.size() > 1), null);
}
 
Example 4
Source File: UIGit.java    From hop with Apache License 2.0 5 votes vote down vote up
@Override
public boolean commit( String authorName, String message ) {
  PersonIdent author = RawParseUtils.parsePersonIdent( authorName );
  // Set the local time
  PersonIdent author2 = new PersonIdent( author.getName(), author.getEmailAddress(),
      SystemReader.getInstance().getCurrentTime(),
      SystemReader.getInstance().getTimezone( SystemReader.getInstance().getCurrentTime() ) );
  try {
    git.commit().setAuthor( author2 ).setMessage( message ).call();
    return true;
  } catch ( Exception e ) {
    showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage() );
    return false;
  }
}
 
Example 5
Source File: GitCommit.java    From app-runner with MIT License 5 votes vote down vote up
public static GitCommit fromHEAD(Git git) throws Exception {
    ObjectId head = git.getRepository().resolve("HEAD");
    if (head != null) {
        RevCommit mostRecentCommit;
        try (RevWalk walk = new RevWalk(git.getRepository())) {
            mostRecentCommit = walk.parseCommit(head);
        }
        Date commitDate = new Date(1000L * mostRecentCommit.getCommitTime());
        String id = mostRecentCommit.getId().name();
        PersonIdent author = mostRecentCommit.getAuthorIdent();
        return new GitCommit(id, commitDate, author.getName(), mostRecentCommit.getFullMessage());
    } else {
        return null;
    }
}
 
Example 6
Source File: NameAndEmail.java    From onedev with MIT License 4 votes vote down vote up
public NameAndEmail(PersonIdent person) {
	this(person.getName(), person.getEmailAddress());
}
 
Example 7
Source File: Commit.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
@PropertyDescription(name = GitConstants.KEY_AUTHOR_NAME)
protected String getAuthorName() {
	PersonIdent author = revCommit.getAuthorIdent();
	return author.getName();
}
 
Example 8
Source File: Commit.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
@PropertyDescription(name = GitConstants.KEY_COMMITTER_NAME)
protected String getCommitterName() {
	PersonIdent committer = revCommit.getCommitterIdent();
	return committer.getName();
}