org.eclipse.jgit.lib.PersonIdent.getName() - java examples

Here are the examples of the java api org.eclipse.jgit.lib.PersonIdent.getName() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

62 Examples 7

19 View Complete Implementation : JGitCommit.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : koraktor
public String getAuthorName() {
    return author.getName();
}

19 View Complete Implementation : SubmoduleSubscriptionsIT.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
@UseClockStep
public void superRepoCommitHreplacedameAuthorreplacedubmoduleCommit() throws Exception {
    // Make sure that the commit is created at an earlier timestamp than the submit timestamp.
    allowMatchingSubmoduleSubscription(subKey, "refs/heads/master", superKey, "refs/heads/master");
    createSubmoduleSubscription(superRepo, "master", subKey, "master");
    PushOneCommit.Result pushResult = createChange(subRepo, "refs/heads/master", "Change", "a.txt", "some content", null);
    approve(pushResult.getChangeId());
    gApi.changes().id(pushResult.getChangeId()).current().submit();
    // Expect that the author name/email is preserved for the superRepo commit, but a new author
    // timestamp is used.
    PersonIdent authorIdent = getAuthor(superRepo, "master");
    replacedertThat(authorIdent.getName()).isEqualTo(admin.fullName());
    replacedertThat(authorIdent.getEmailAddress()).isEqualTo(admin.email());
    replacedertThat(authorIdent.getWhen()).isGreaterThan(pushResult.getCommit().getAuthorIdent().getWhen());
}

19 View Complete Implementation : SystemTestBase.java
Copyright Apache License 2.0
Author : Verigreen
private void replacedertCommit(String commitId, String expectedCommiterName, String expectedCommiterEmail, String expectedCommitMessage) {
    PersonIdent committerIdent = ((JGitOperator) _sourceControlOperator).getRevCommit(commitId).getCommitterIdent();
    String commitMessage = ((JGitOperator) _sourceControlOperator).getRevCommit(commitId).getFullMessage();
    replacedert.replacedertEquals(expectedCommiterName, committerIdent.getName());
    replacedert.replacedertEquals(expectedCommiterEmail, committerIdent.getEmailAddress());
    replacedert.replacedertEquals(expectedCommitMessage, commitMessage);
}

19 View Complete Implementation : TagHelper.java
Copyright MIT License
Author : dmusican
/**
 * @return the name of the author of this tag
 */
public String getAuthorName() {
    return author.getName();
}

19 View Complete Implementation : CommitHelper.java
Copyright MIT License
Author : dmusican
/**
 * @return the name of the author of this commit
 */
public String getAuthorName() {
    return author.getName();
}

19 View Complete Implementation : JGitCommit.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : koraktor
public String getCommitterName() {
    return committer.getName();
}

19 View Complete Implementation : GitAuthor.java
Copyright Apache License 2.0
Author : softvis-research
@Override
public String getName() {
    return authorIdent.getName();
}

18 View Complete Implementation : GetPatch.java
Copyright Apache License 2.0
Author : gerrit-review
private static String formatEmailHeader(RevCommit commit) {
    StringBuilder b = new StringBuilder();
    PersonIdent author = commit.getAuthorIdent();
    String subject = commit.getShortMessage();
    String msg = commit.getFullMessage().substring(subject.length());
    if (msg.startsWith("\n\n")) {
        msg = msg.substring(2);
    }
    b.append("From ").append(commit.getName()).append(' ').append(// Fixed timestamp to match output of C Git's format-patch
    "Mon Sep 17 00:00:00 2001\n").append("From: ").append(author.getName()).append(" <").append(author.getEmailAddress()).append(">\n").append("Date: ").append(formatDate(author)).append('\n').append("Subject: [PATCH] ").append(subject).append('\n').append('\n').append(msg);
    if (!msg.endsWith("\n")) {
        b.append('\n');
    }
    return b.append("---\n\n").toString();
}

18 View Complete Implementation : SubmoduleSubscriptionsIT.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
@UseClockStep
public void superRepoCommitHreplacedameAuthorreplacedubmoduleCommits() throws Exception {
    replacedume().that(isSubmitWholeTopicEnabled()).isTrue();
    Project.NameKey proj2 = createProjectForPush(getSubmitType());
    TestRepository<?> subRepo2 = cloneProject(proj2);
    allowMatchingSubmoduleSubscription(subKey, "refs/heads/master", superKey, "refs/heads/master");
    allowMatchingSubmoduleSubscription(proj2, "refs/heads/master", superKey, "refs/heads/master");
    Config config = new Config();
    prepareSubmoduleConfigEntry(config, subKey, subKey, "master");
    prepareSubmoduleConfigEntry(config, proj2, proj2, "master");
    pushSubmoduleConfig(superRepo, "master", config);
    String topic = "foo";
    PushOneCommit.Result pushResult1 = createChange(subRepo, "refs/heads/master", "Change 1", "a.txt", "some content", topic);
    approve(pushResult1.getChangeId());
    PushOneCommit.Result pushResult2 = createChange(subRepo2, "refs/heads/master", "Change 2", "b.txt", "other content", topic);
    approve(pushResult2.getChangeId());
    // Submit the topic, 2 changes with the same author.
    gApi.changes().id(pushResult1.getChangeId()).current().submit();
    // Expect that the author name/email is preserved for the superRepo commit, but a new author
    // timestamp is used.
    PersonIdent authorIdent = getAuthor(superRepo, "master");
    replacedertThat(authorIdent.getName()).isEqualTo(admin.fullName());
    replacedertThat(authorIdent.getEmailAddress()).isEqualTo(admin.email());
    replacedertThat(authorIdent.getWhen()).isGreaterThan(pushResult1.getCommit().getAuthorIdent().getWhen());
    replacedertThat(authorIdent.getWhen()).isGreaterThan(pushResult2.getCommit().getAuthorIdent().getWhen());
}

18 View Complete Implementation : BlameCommit.java
Copyright MIT License
Author : theonedev
@Override
public String toString() {
    return MoreObjects.toStringHelper(this).add("hash", hash).add("committer", committer.getName()).add("date", committer.getWhen()).add("messageSummary", subject).toString();
}

18 View Complete Implementation : CommitCriteria.java
Copyright MIT License
Author : theonedev
protected boolean matches(String value, PersonIdent person) {
    String formatted = String.format("%s <%s>", person.getName(), person.getEmailAddress());
    return WildcardUtils.matchString(value, formatted);
}

18 View Complete Implementation : GitCommit.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : gluonhq
public String getAuthor() {
    PersonIdent personId = commit.getAuthorIdent();
    return String.format("%s<%s>", personId.getName(), personId.getEmailAddress());
}

18 View Complete Implementation : CommitMessageOutputTest.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
public void realUser() throws Exception {
    Change c = newChange();
    CurrentUser ownerAsOtherUser = userFactory.runAs(null, otherUserId, changeOwner);
    ChangeUpdate update = newUpdate(c, ownerAsOtherUser);
    update.setChangeMessage("Message on behalf of other user");
    update.commit();
    RevCommit commit = parseCommit(update.getResult());
    PersonIdent author = commit.getAuthorIdent();
    replacedertThat(author.getName()).isEqualTo("Gerrit User 2");
    replacedertThat(author.getEmailAddress()).isEqualTo("2@gerrit");
    replacedertBodyEquals("Update patch set 1\n" + "\n" + "Message on behalf of other user\n" + "\n" + "Patch-set: 1\n" + "Real-user: Gerrit User 1 <1@gerrit>\n", commit);
}

17 View Complete Implementation : Commit.java
Copyright Eclipse Public License 1.0
Author : eclipse
@PropertyDescription(name = GitConstants.KEY_AUTHOR_NAME)
protected String getAuthorName() {
    PersonIdent author = revCommit.getAuthorIdent();
    return author.getName();
}

17 View Complete Implementation : PatchSetInfoFactory.java
Copyright Apache License 2.0
Author : gerrit-review
// TODO: The same method exists in EventFactory, find a common place for it
private UserIdenreplacedy toUserIdenreplacedy(PersonIdent who) throws IOException, OrmException {
    final UserIdenreplacedy u = new UserIdenreplacedy();
    u.setName(who.getName());
    u.setEmail(who.getEmailAddress());
    u.setDate(new Timestamp(who.getWhen().getTime()));
    u.setTimeZone(who.getTimeZoneOffset());
    // If only one account has access to this email address, select it
    // as the idenreplacedy of the user.
    // 
    Set<Account.Id> a = emails.getAccountFor(u.getEmail());
    if (a.size() == 1) {
        u.setAccount(a.iterator().next());
    }
    return u;
}

17 View Complete Implementation : CommitMessageOutputTest.java
Copyright Apache License 2.0
Author : gerrit-review
@Test
public void realUser() throws Exception {
    Change c = newChange();
    CurrentUser ownerAsOtherUser = userFactory.runAs(null, otherUserId, changeOwner);
    ChangeUpdate update = newUpdate(c, ownerAsOtherUser);
    update.setChangeMessage("Message on behalf of other user");
    update.commit();
    RevCommit commit = parseCommit(update.getResult());
    PersonIdent author = commit.getAuthorIdent();
    replacedertThat(author.getName()).isEqualTo("Other Account");
    replacedertThat(author.getEmailAddress()).isEqualTo("2@gerrit");
    replacedertBodyEquals("Update patch set 1\n" + "\n" + "Message on behalf of other user\n" + "\n" + "Patch-set: 1\n" + "Real-user: Change Owner <1@gerrit>\n", commit);
}

17 View Complete Implementation : GitPersonSubject.java
Copyright Apache License 2.0
Author : GerritCodeReview
public void matches(PersonIdent ident) {
    isNotNull();
    name().isEqualTo(ident.getName());
    email().isEqualTo(ident.getEmailAddress());
    check("roundedDate()").that(new Date(gitPerson.date.getTime())).isEqualTo(ident.getWhen());
    tz().isEqualTo(ident.getTimeZoneOffset());
}

17 View Complete Implementation : ChangeUpdate.java
Copyright Apache License 2.0
Author : GerritCodeReview
private StringBuilder addIdent(StringBuilder sb, Account.Id accountId) {
    PersonIdent ident = newIdent(accountId, when);
    PersonIdent.appendSanitized(sb, ident.getName());
    sb.append(" <");
    PersonIdent.appendSanitized(sb, ident.getEmailAddress());
    sb.append('>');
    return sb;
}

17 View Complete Implementation : Text.java
Copyright Apache License 2.0
Author : gerrit-review
private static void appendPersonIdent(StringBuilder b, String field, PersonIdent person) {
    if (person != null) {
        b.append(field).append(":    ");
        if (person.getName() != null) {
            b.append(" ");
            b.append(person.getName());
        }
        if (person.getEmailAddress() != null) {
            b.append(" <");
            b.append(person.getEmailAddress());
            b.append(">");
        }
        b.append("\n");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZ");
        sdf.setTimeZone(person.getTimeZone());
        b.append(field).append("Date: ");
        b.append(sdf.format(person.getWhen()));
        b.append("\n");
    }
}

17 View Complete Implementation : SubmoduleSubscriptionsIT.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
@UseClockStep
public void superRepoCommitHasGerritAsAuthorIfAuthorsOfSubmoduleCommitsDiffer() throws Exception {
    replacedume().that(isSubmitWholeTopicEnabled()).isTrue();
    Project.NameKey proj2 = createProjectForPush(getSubmitType());
    TestRepository<InMemoryRepository> repo2 = cloneProject(proj2, user);
    allowMatchingSubmoduleSubscription(subKey, "refs/heads/master", superKey, "refs/heads/master");
    allowMatchingSubmoduleSubscription(proj2, "refs/heads/master", superKey, "refs/heads/master");
    Config config = new Config();
    prepareSubmoduleConfigEntry(config, subKey, subKey, "master");
    prepareSubmoduleConfigEntry(config, proj2, proj2, "master");
    pushSubmoduleConfig(superRepo, "master", config);
    String topic = "foo";
    // Create change as admin.
    PushOneCommit.Result pushResult1 = createChange(subRepo, "refs/heads/master", "Change 1", "a.txt", "some content", topic);
    approve(pushResult1.getChangeId());
    // Create change as user.
    PushOneCommit push = pushFactory.create(user.newIdent(), repo2, "Change 2", "b.txt", "other content");
    PushOneCommit.Result pushResult2 = push.to("refs/for/master%topic=" + name(topic));
    approve(pushResult2.getChangeId());
    // Submit the topic, 2 changes with the different author.
    gApi.changes().id(pushResult1.getChangeId()).current().submit();
    // Expect that the Gerrit server idenreplacedy is chosen as author for the superRepo commit and a
    // new author timestamp is used.
    PersonIdent authorIdent = getAuthor(superRepo, "master");
    replacedertThat(authorIdent.getName()).isEqualTo(serverIdent.get().getName());
    replacedertThat(authorIdent.getEmailAddress()).isEqualTo(serverIdent.get().getEmailAddress());
    replacedertThat(authorIdent.getWhen()).isGreaterThan(pushResult1.getCommit().getAuthorIdent().getWhen());
    replacedertThat(authorIdent.getWhen()).isGreaterThan(pushResult2.getCommit().getAuthorIdent().getWhen());
}

17 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
public void CUSTOM_NullUser() {
    setFrom("A ${user} B <[email protected]>");
    final Address r = create().from(null);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo("[email protected]");
}

17 View Complete Implementation : RefLogUtils.java
Copyright Apache License 2.0
Author : gitblit
private static UserModel newUserModelFrom(PersonIdent ident) {
    String name = ident.getName();
    String username;
    String displayname;
    if (name.indexOf('/') > -1) {
        int slash = name.indexOf('/');
        displayname = name.substring(0, slash);
        username = name.substring(slash + 1);
    } else {
        displayname = name;
        username = ident.getEmailAddress();
    }
    UserModel user = new UserModel(username);
    user.displayName = displayname;
    user.emailAddress = ident.getEmailAddress();
    return user;
}

17 View Complete Implementation : AbstractGitAPIImpl.java
Copyright MIT License
Author : jenkinsci
/**
 * {@inheritDoc}
 */
public void setAuthor(PersonIdent p) {
    if (p != null)
        setAuthor(p.getName(), p.getEmailAddress());
}

17 View Complete Implementation : AbstractGitAPIImpl.java
Copyright MIT License
Author : jenkinsci
/**
 * {@inheritDoc}
 */
public void setCommitter(PersonIdent p) {
    if (p != null)
        setCommitter(p.getName(), p.getEmailAddress());
}

17 View Complete Implementation : RepositoryUtilsConfigTest.java
Copyright Apache License 2.0
Author : beijunyi
@Test
public void setDefaultCommitter_newPersonIdentInstanceShouldHaveTheSpecifiedUserNameAndEmail() throws IOException {
    String name = "test_user";
    String email = "[email protected]";
    RepositoryUtils.setDefaultCommitter(name, email, repo);
    PersonIdent actual = new PersonIdent(repo);
    replacedertEquals(name, actual.getName());
    replacedertEquals(email, actual.getEmailAddress());
}

17 View Complete Implementation : GitBlameCommandTest.java
Copyright Apache License 2.0
Author : box
@Test
public void getBlameResultForLines() throws Exception {
    if (shallowClone) {
        // that won't work on a shallow clone / on travis. Keep it for local testing
        return;
    }
    File sourceDirectory = getInputResourcesTestDir("source");
    String filepath = sourceDirectory.getAbsolutePath();
    GitBlameCommand gitBlameCommand = new GitBlameCommand();
    gitBlameCommand.commandDirectories = new CommandDirectories(filepath);
    gitBlameCommand.initGitRepository();
    String relativePath = gitBlameCommand.gitRepository.getDirectory().toPath().getParent().relativize(sourceDirectory.toPath()).toString();
    relativePath = relativePath + "/res/values/strings.xml";
    BlameResult blameResult = gitBlameCommand.gitRepository.getBlameResultForFile(relativePath);
    // Will not hold up if file is committed by another person and/or at another time
    String expectedAuthor = "Liz Magalindan";
    String expectedEmail = "[email protected]";
    String expectedSourceCommit = "88025e7b8b0f5d0f12f90c4ed9f86623074bc2ee";
    int expectedTime = 1537477876;
    for (int lineNumber = 0; lineNumber < blameResult.getResultContents().size(); lineNumber++) {
        PersonIdent actualAuthor = blameResult.getSourceAuthor(lineNumber);
        RevCommit actualCommit = blameResult.getSourceCommit(lineNumber);
        replacedertEquals(expectedAuthor, actualAuthor.getName());
        replacedertEquals(expectedEmail, actualAuthor.getEmailAddress());
        replacedertEquals(expectedSourceCommit, actualCommit.getName());
        replacedertEquals(expectedTime, actualCommit.getCommitTime());
    }
}

16 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : gerrit-review
@Test
public void CUSTOM_NullUser() {
    setFrom("A ${user} B <[email protected]>");
    replay(accountCache);
    final Address r = create().from(null);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo("[email protected]");
    verify(accountCache);
}

16 View Complete Implementation : CommitMessageOutputTest.java
Copyright Apache License 2.0
Author : gerrit-review
@Test
public void anonymousUser() throws Exception {
    Account anon = new Account(new Account.Id(3), TimeUtil.nowTs());
    accountCache.put(anon);
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, userFactory.create(anon.getId()));
    update.setChangeMessage("Comment on the change.");
    update.commit();
    RevCommit commit = parseCommit(update.getResult());
    replacedertBodyEquals("Update patch set 1\n\nComment on the change.\n\nPatch-set: 1\n", commit);
    PersonIdent author = commit.getAuthorIdent();
    replacedertThat(author.getName()).isEqualTo("Anonymous Coward (3)");
    replacedertThat(author.getEmailAddress()).isEqualTo("3@gerrit");
}

16 View Complete Implementation : Emails.java
Copyright Apache License 2.0
Author : GerritCodeReview
public UserIdenreplacedy toUserIdenreplacedy(PersonIdent who) throws IOException {
    UserIdenreplacedy u = new UserIdenreplacedy();
    u.setName(who.getName());
    u.setEmail(who.getEmailAddress());
    u.setDate(new Timestamp(who.getWhen().getTime()));
    u.setTimeZone(who.getTimeZoneOffset());
    // If only one account has access to this email address, select it
    // as the idenreplacedy of the user.
    // 
    Set<Account.Id> a = getAccountFor(u.getEmail());
    if (a.size() == 1) {
        u.setAccount(a.iterator().next());
    }
    return u;
}

16 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
public void USER_NullUser() {
    setFrom("USER");
    final Address r = create().from(null);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo(ident.getEmailAddress());
    verifyZeroInteractions(accountCache);
}

16 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
public void SERVER_FullyConfiguredUser() {
    setFrom("SERVER");
    final String name = "A U. Thor";
    final String email = "[email protected]";
    final Account.Id user = userNoLookup(name, email);
    final Address r = create().from(user);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo(ident.getEmailAddress());
    verifyZeroInteractions(accountCache);
}

16 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
public void MIXED_NullUser() {
    setFrom("MIXED");
    final Address r = create().from(null);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo(ident.getEmailAddress());
    verifyZeroInteractions(accountCache);
}

16 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
public void SERVER_NullUser() {
    setFrom("SERVER");
    final Address r = create().from(null);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo(ident.getEmailAddress());
    verifyZeroInteractions(accountCache);
}

16 View Complete Implementation : CommitMessageOutputTest.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
public void anonymousUser() throws Exception {
    Account anon = Account.builder(Account.id(3), TimeUtil.nowTs()).setMetaId("1234567812345678123456781234567812345678").build();
    accountCache.put(anon);
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, userFactory.create(anon.id()));
    update.setChangeMessage("Comment on the change.");
    update.commit();
    RevCommit commit = parseCommit(update.getResult());
    replacedertBodyEquals("Update patch set 1\n\nComment on the change.\n\nPatch-set: 1\n", commit);
    PersonIdent author = commit.getAuthorIdent();
    replacedertThat(author.getName()).isEqualTo("Gerrit User 3");
    replacedertThat(author.getEmailAddress()).isEqualTo("3@gerrit");
}

16 View Complete Implementation : CommitMessageOutputTest.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
public void submitCommitFormat() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.setSubjectForCommit("Submit patch set 1");
    SubmissionId submissionId = new SubmissionId(c);
    update.merge(submissionId, ImmutableList.of(submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Code-Review", "NEED", null)), submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Alternative-Code-Review", "NEED", null))));
    update.commit();
    RevCommit commit = parseCommit(update.getResult());
    replacedertBodyEquals("Submit patch set 1\n" + "\n" + "Patch-set: 1\n" + "Status: merged\n" + "Submission-id: " + submissionId.toString() + "\n" + "Submitted-with: NOT_READY\n" + "Submitted-with: OK: Verified: Gerrit User 1 <1@gerrit>\n" + "Submitted-with: NEED: Code-Review\n" + "Submitted-with: NOT_READY\n" + "Submitted-with: OK: Verified: Gerrit User 1 <1@gerrit>\n" + "Submitted-with: NEED: Alternative-Code-Review\n", commit);
    PersonIdent author = commit.getAuthorIdent();
    replacedertThat(author.getName()).isEqualTo("Gerrit User 1");
    replacedertThat(author.getEmailAddress()).isEqualTo("1@gerrit");
    replacedertThat(author.getWhen()).isEqualTo(new Date(c.getCreatedOn().getTime() + 2000));
    replacedertThat(author.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT-7:00"));
    PersonIdent committer = commit.getCommitterIdent();
    replacedertThat(committer.getName()).isEqualTo("Gerrit Server");
    replacedertThat(committer.getEmailAddress()).isEqualTo("[email protected]");
    replacedertThat(committer.getWhen()).isEqualTo(author.getWhen());
    replacedertThat(committer.getTimeZone()).isEqualTo(author.getTimeZone());
}

16 View Complete Implementation : CommitMessageOutputTest.java
Copyright Apache License 2.0
Author : GerritCodeReview
@Test
public void approvalsCommitFormatSimple() throws Exception {
    Change c = TestChanges.newChange(project, changeOwner.getAccountId(), 1);
    ChangeUpdate update = newUpdateForNewChange(c, changeOwner);
    update.putApproval("Verified", (short) 1);
    update.putApproval("Code-Review", (short) -1);
    update.putReviewer(changeOwner.getAccount().id(), REVIEWER);
    update.putReviewer(otherUser.getAccount().id(), CC);
    update.commit();
    replacedertThat(update.getRefName()).isEqualTo("refs/changes/01/1/meta");
    RevCommit commit = parseCommit(update.getResult());
    replacedertBodyEquals("Update patch set 1\n" + "\n" + "Patch-set: 1\n" + "Change-id: " + c.getKey().get() + "\n" + "Subject: Change subject\n" + "Branch: refs/heads/master\n" + "Commit: " + update.getCommit().name() + "\n" + "Reviewer: Gerrit User 1 <1@gerrit>\n" + "CC: Gerrit User 2 <2@gerrit>\n" + "Label: Code-Review=-1\n" + "Label: Verified=+1\n", commit);
    PersonIdent author = commit.getAuthorIdent();
    replacedertThat(author.getName()).isEqualTo("Gerrit User 1");
    replacedertThat(author.getEmailAddress()).isEqualTo("1@gerrit");
    replacedertThat(author.getWhen()).isEqualTo(new Date(c.getCreatedOn().getTime() + 1000));
    replacedertThat(author.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT-7:00"));
    PersonIdent committer = commit.getCommitterIdent();
    replacedertThat(committer.getName()).isEqualTo("Gerrit Server");
    replacedertThat(committer.getEmailAddress()).isEqualTo("[email protected]");
    replacedertThat(committer.getWhen()).isEqualTo(author.getWhen());
    replacedertThat(committer.getTimeZone()).isEqualTo(author.getTimeZone());
}

16 View Complete Implementation : DefaultAvatarManager.java
Copyright MIT License
Author : theonedev
@Sessional
@Override
public String getAvatarUrl(PersonIdent personIdent) {
    if (StringUtils.isBlank(personIdent.getEmailAddress())) {
        if (personIdent.getName().equals(OneDev.NAME))
            return AVATARS_BASE_URL + "onedev.png";
        else
            return AVATARS_BASE_URL + "user.png";
    } else {
        User user = userManager.findByEmail(personIdent.getEmailAddress());
        if (user != null) {
            File uploadedFile = getUploaded(user);
            if (uploadedFile.exists())
                return AVATARS_BASE_URL + "uploaded/users/" + user.getId() + ".jpg?version=" + uploadedFile.lastModified();
        }
        if (settingManager.getSystemSetting().isGravatarEnabled())
            return Gravatar.getURL(personIdent.getEmailAddress(), GRAVATAR_SIZE);
        else
            return generateAvatar(personIdent.getName(), personIdent.getEmailAddress());
    }
}

16 View Complete Implementation : GitRevision.java
Copyright GNU General Public License v2.0
Author : bozaro
@Nullable
public String getAuthor() {
    if (gitNewCommit == null)
        return null;
    final PersonIdent ident = gitNewCommit.getAuthorIdent();
    return String.format("%s <%s>", ident.getName(), ident.getEmailAddress());
}

16 View Complete Implementation : Commit.java
Copyright Eclipse Public License 1.0
Author : eclipse
@PropertyDescription(name = GitConstants.KEY_COMMITTER_NAME)
protected String getCommitterName() {
    PersonIdent committer = revCommit.getCommitterIdent();
    return committer.getName();
}

16 View Complete Implementation : ChangeField.java
Copyright Apache License 2.0
Author : gerrit-review
private static Set<String> getNameAndEmail(PersonIdent person) {
    if (person == null) {
        return ImmutableSet.of();
    }
    String name = person.getName().toLowerCase(Locale.US);
    String email = person.getEmailAddress().toLowerCase(Locale.US);
    StringBuilder nameEmailBuilder = new StringBuilder();
    PersonIdent.appendSanitized(nameEmailBuilder, name);
    nameEmailBuilder.append(" <");
    PersonIdent.appendSanitized(nameEmailBuilder, email);
    nameEmailBuilder.append('>');
    return ImmutableSet.of(name, email, nameEmailBuilder.toString());
}

16 View Complete Implementation : ChangeUpdate.java
Copyright Apache License 2.0
Author : gerrit-review
private StringBuilder addIdent(StringBuilder sb, Account.Id accountId) {
    Account account = accountCache.get(accountId).getAccount();
    PersonIdent ident = newIdent(account, when);
    PersonIdent.appendSanitized(sb, ident.getName());
    sb.append(" <");
    PersonIdent.appendSanitized(sb, ident.getEmailAddress());
    sb.append('>');
    return sb;
}

16 View Complete Implementation : AbstractSubmit.java
Copyright Apache License 2.0
Author : gerrit-review
protected void replacedertPersonEquals(PersonIdent expected, PersonIdent actual) {
    replacedertThat(actual.getEmailAddress()).isEqualTo(expected.getEmailAddress());
    replacedertThat(actual.getName()).isEqualTo(expected.getName());
    replacedertThat(actual.getTimeZone()).isEqualTo(expected.getTimeZone());
}

15 View Complete Implementation : SchemaUtil.java
Copyright Apache License 2.0
Author : gerrit-review
public static Set<String> getPersonParts(PersonIdent person) {
    if (person == null) {
        return ImmutableSet.of();
    }
    return getNameParts(person.getName(), Collections.singleton(person.getEmailAddress()));
}

15 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : gerrit-review
@Test
public void SERVER_FullyConfiguredUser() {
    setFrom("SERVER");
    final String name = "A U. Thor";
    final String email = "[email protected]";
    final Account.Id user = userNoLookup(name, email);
    replay(accountCache);
    final Address r = create().from(user);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo(ident.getEmailAddress());
    verify(accountCache);
}

15 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : gerrit-review
@Test
public void SERVER_NullUser() {
    setFrom("SERVER");
    replay(accountCache);
    final Address r = create().from(null);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo(ident.getEmailAddress());
    verify(accountCache);
}

15 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : gerrit-review
@Test
public void MIXED_NullUser() {
    setFrom("MIXED");
    replay(accountCache);
    final Address r = create().from(null);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo(ident.getEmailAddress());
    verify(accountCache);
}

15 View Complete Implementation : FromAddressGeneratorProviderTest.java
Copyright Apache License 2.0
Author : gerrit-review
@Test
public void USER_NullUser() {
    setFrom("USER");
    replay(accountCache);
    final Address r = create().from(null);
    replacedertThat(r).isNotNull();
    replacedertThat(r.getName()).isEqualTo(ident.getName());
    replacedertThat(r.getEmail()).isEqualTo(ident.getEmailAddress());
    verify(accountCache);
}

15 View Complete Implementation : CommitMessageOutputTest.java
Copyright Apache License 2.0
Author : gerrit-review
@Test
public void approvalsCommitFormatSimple() throws Exception {
    Change c = TestChanges.newChange(project, changeOwner.getAccountId(), 1);
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.putApproval("Verified", (short) 1);
    update.putApproval("Code-Review", (short) -1);
    update.putReviewer(changeOwner.getAccount().getId(), REVIEWER);
    update.putReviewer(otherUser.getAccount().getId(), CC);
    update.commit();
    replacedertThat(update.getRefName()).isEqualTo("refs/changes/01/1/meta");
    RevCommit commit = parseCommit(update.getResult());
    replacedertBodyEquals("Update patch set 1\n" + "\n" + "Patch-set: 1\n" + "Change-id: " + c.getKey().get() + "\n" + "Subject: Change subject\n" + "Branch: refs/heads/master\n" + "Commit: " + update.getCommit().name() + "\n" + "Reviewer: Change Owner <1@gerrit>\n" + "CC: Other Account <2@gerrit>\n" + "Label: Code-Review=-1\n" + "Label: Verified=+1\n", commit);
    PersonIdent author = commit.getAuthorIdent();
    replacedertThat(author.getName()).isEqualTo("Change Owner");
    replacedertThat(author.getEmailAddress()).isEqualTo("1@gerrit");
    replacedertThat(author.getWhen()).isEqualTo(new Date(c.getCreatedOn().getTime() + 1000));
    replacedertThat(author.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT-7:00"));
    PersonIdent committer = commit.getCommitterIdent();
    replacedertThat(committer.getName()).isEqualTo("Gerrit Server");
    replacedertThat(committer.getEmailAddress()).isEqualTo("[email protected]");
    replacedertThat(committer.getWhen()).isEqualTo(author.getWhen());
    replacedertThat(committer.getTimeZone()).isEqualTo(author.getTimeZone());
}

15 View Complete Implementation : CommitSoyData.java
Copyright Apache License 2.0
Author : google
// TODO(dborowitz): Extract this.
public static Map<String, String> toSoyData(PersonIdent ident, DateFormatter df) {
    return ImmutableMap.of("name", ident.getName(), "email", ident.getEmailAddress(), "time", df.format(ident), // TODO(dborowitz): Switch from relative to absolute at some threshold.
    "relativeTime", RelativeDateFormatter.format(ident.getWhen()));
}

15 View Complete Implementation : PersonCardPanel.java
Copyright MIT License
Author : theonedev
@Override
protected void onInitialize() {
    super.onInitialize();
    WebMarkupContainer container = new WebMarkupContainer("container");
    add(container);
    container.add(new UserAvatar("avatar", personIdent));
    StringBuilder builder = new StringBuilder();
    builder.append("<div>" + HtmlEscape.escapeHtml5(personIdent.getName()) + " <i>(" + gitRole + ")</i></div>");
    if (StringUtils.isBlank(personIdent.getEmailAddress())) {
        if (personIdent.getName().equals(OneDev.NAME))
            builder.append("<i>System Account</i>");
        else
            builder.append("<i>No Email Address</i>");
    } else {
        User user = OneDev.getInstance(UserManager.clreplaced).findByEmail(personIdent.getEmailAddress());
        if (user != null)
            builder.append("<div>" + HtmlEscape.escapeHtml5(user.getName()) + " <i>(Account in OneDev)</i>");
        else
            builder.append("<i>No OneDev Account</i>");
        builder.append("<div><a href='mailto:" + personIdent.getEmailAddress() + "'>" + HtmlEscape.escapeHtml5(personIdent.getEmailAddress()) + "</a></div>");
        container.add(AttributeAppender.append("clreplaced", "bigger"));
    }
    container.add(new Label("info", builder.toString()).setEscapeModelStrings(false));
}