Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.PersonIdent


    final RevWalk revWalk = new RevWalk(git);
    try {
      RevCommit commitToRevert =
          revWalk.parseCommit(ObjectId.fromString(patch.getRevision().get()));

      PersonIdent authorIdent =
          user.newCommitterIdent(myIdent.getWhen(), myIdent.getTimeZone());

      RevCommit parentToCommitToRevert = commitToRevert.getParent(0);
      revWalk.parseHeaders(parentToCommitToRevert);
View Full Code Here


        outw.print(")"); //$NON-NLS-1$
      }
    }
    outw.println();

    final PersonIdent author = c.getAuthorIdent();
    outw.println(MessageFormat.format(CLIText.get().authorInfo, author.getName(), author.getEmailAddress()));
    outw.println(MessageFormat.format(CLIText.get().dateInfo,
        dateFormatter.formatDate(author)));

    outw.println();
    final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
View Full Code Here

    String p = blame.getSourcePath(line);
    return p != null ? p : ""; //$NON-NLS-1$
  }

  private String author(int line) {
    PersonIdent author = blame.getSourceAuthor(line);
    if (author == null)
      return ""; //$NON-NLS-1$
    String name = showAuthorEmail ? author.getEmailAddress() : author
        .getName();
    return name != null ? name : ""; //$NON-NLS-1$
  }
View Full Code Here

  private String date(int line) {
    if (blame.getSourceCommit(line) == null)
      return ""; //$NON-NLS-1$

    PersonIdent author = blame.getSourceAuthor(line);
    if (author == null)
      return ""; //$NON-NLS-1$

    dateFmt.setTimeZone(author.getTimeZone());
    if (!showRawTimestamp)
      return dateFmt.format(author.getWhen());
    return String.format("%d %s", //$NON-NLS-1$
        valueOf(author.getWhen().getTime() / 1000L),
        dateFmt.format(author.getWhen()));
  }
View Full Code Here

     * @param nameEnvKey String.
     * @param emailEnvKey String.
     * @return person instance
     */
    private PersonIdent buildPersonIdent(EnvVars envVars, String nameEnvKey, String emailEnvKey) {
        PersonIdent result = null;
        if (null != envVars) {
            String name = envVars.get(nameEnvKey);
            String email = envVars.get(emailEnvKey);
            if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(email)) {
                result = new PersonIdent(name, email);
            }
        }
        return result;
    }
View Full Code Here

      return Integer.MAX_VALUE;
    }

    @Override
    PersonIdent getAuthor() {
      return new PersonIdent(description, "");
    }
View Full Code Here

    // before the LF in case of LF termination resp. the penultimate
    // character if there is no trailing LF.
    final int tzBegin = lastIndexOfTrim(raw, ' ',
        nextLF(raw, emailE - 1) - 2) + 1;
    if (tzBegin <= emailE) // No time/zone, still valid
      return new PersonIdent(name, email, 0, 0);

    final int whenBegin = Math.max(emailE,
        lastIndexOfTrim(raw, ' ', tzBegin - 1) + 1);
    if (whenBegin >= tzBegin - 1) // No time/zone, still valid
      return new PersonIdent(name, email, 0, 0);

    final long when = parseLongBase10(raw, whenBegin, null);
    final int tz = parseTimeZoneOffset(raw, tzBegin);
    return new PersonIdent(name, email, when * 1000L, tz);
  }
View Full Code Here

      tz = parseTimeZoneOffset(raw, ptrout.value);
    } else {
      when = 0;
      tz = 0;
    }
    return new PersonIdent(name, email, when * 1000L, tz);
  }
View Full Code Here

    }

    pm.beginTask("Rewriting commits", queue.size());
    final ObjectInserter oi = db.newObjectInserter();
    final ObjectId emptyTree = oi.insert(Constants.OBJ_TREE, new byte[] {});
    final PersonIdent me = new PersonIdent("jgit rebuild-commitgraph", //$NON-NLS-1$
        "rebuild-commitgraph@localhost"); //$NON-NLS-1$
    while (!queue.isEmpty()) {
      final ListIterator<ToRewrite> itr = queue
          .listIterator(queue.size());
      queue = new ArrayList<ToRewrite>();
      REWRITE: while (itr.hasPrevious()) {
        final ToRewrite t = itr.previous();
        final ObjectId[] newParents = new ObjectId[t.oldParents.length];
        for (int k = 0; k < t.oldParents.length; k++) {
          final ToRewrite p = toRewrite.get(t.oldParents[k]);
          if (p != null) {
            if (p.newId == null) {
              // Must defer until after the parent is rewritten.
              queue.add(t);
              continue REWRITE;
            } else {
              newParents[k] = p.newId;
            }
          } else {
            // We have the old parent object. Use it.
            //
            newParents[k] = t.oldParents[k];
          }
        }

        final CommitBuilder newc = new CommitBuilder();
        newc.setTreeId(emptyTree);
        newc.setAuthor(new PersonIdent(me, new Date(t.commitTime)));
        newc.setCommitter(newc.getAuthor());
        newc.setParentIds(newParents);
        newc.setMessage("ORIGINAL " + t.oldId.name() + "\n"); //$NON-NLS-2$
        t.newId = oi.insert(newc);
        rewrites.put(t.oldId, t.newId);
View Full Code Here

public class JGitUtilsTest extends GitblitUnitTest {

  @Test
  public void testDisplayName() throws Exception {
    assertEquals("Napoleon Bonaparte",
        JGitUtils.getDisplayName(new PersonIdent("Napoleon Bonaparte", "")));
    assertEquals("<someone@somewhere.com>",
        JGitUtils.getDisplayName(new PersonIdent("", "someone@somewhere.com")));
    assertEquals("Napoleon Bonaparte <someone@somewhere.com>",
        JGitUtils.getDisplayName(new PersonIdent("Napoleon Bonaparte",
            "someone@somewhere.com")));
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.PersonIdent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.