Examples of ReflogEntry


Examples of org.eclipse.jgit.lib.ReflogEntry

  @Test
  public void testReadOneLine() throws Exception {
    setupReflog("logs/refs/heads/master", oneLine);

    ReflogReader reader = new ReflogReaderImpl(db, "refs/heads/master");
    ReflogEntry e = reader.getLastEntry();
    assertEquals(ObjectId
        .fromString("da85355dfc525c9f6f3927b876f379f46ccf826e"), e
        .getOldId());
    assertEquals(ObjectId
        .fromString("3e7549db262d1e836d9bf0af7e22355468f1717c"), e
        .getNewId());
    assertEquals("A O Thor Too", e.getWho().getName());
    assertEquals("authortoo@wri.tr", e.getWho().getEmailAddress());
    assertEquals(120, e.getWho().getTimeZoneOffset());
    assertEquals("2009-05-22T23:36:40", iso(e.getWho()));
    assertEquals("commit: Add a toString for debugging to RemoteRefUpdate",
        e.getComment());
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.ReflogEntry

    setupReflog("logs/refs/heads/master", twoLine);

    ReflogReader reader = new ReflogReaderImpl(db, "refs/heads/master");
    List<ReflogEntry> reverseEntries = reader.getReverseEntries();
    assertEquals(2, reverseEntries.size());
    ReflogEntry e = reverseEntries.get(0);
    assertEquals(ObjectId
        .fromString("c6734895958052a9dbc396cff4459dc1a25029ab"), e
        .getOldId());
    assertEquals(ObjectId
        .fromString("54794942a18a237c57a80719afed44bb78172b10"), e
        .getNewId());
    assertEquals("Same A U Thor", e.getWho().getName());
    assertEquals("same.author@example.com", e.getWho().getEmailAddress());
    assertEquals(60, e.getWho().getTimeZoneOffset());
    assertEquals("2009-05-22T22:36:42", iso(e.getWho()));
    assertEquals(
        "rebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d",
        e.getComment());

    e = reverseEntries.get(1);
    assertEquals(ObjectId
        .fromString("0000000000000000000000000000000000000000"), e
        .getOldId());
    assertEquals(ObjectId
        .fromString("c6734895958052a9dbc396cff4459dc1a25029ab"), e
        .getNewId());
    assertEquals("A U Thor", e.getWho().getName());
    assertEquals("thor@committer.au", e.getWho().getEmailAddress());
    assertEquals(-60, e.getWho().getTimeZoneOffset());
    assertEquals("2009-05-22T20:36:41", iso(e.getWho()));
    assertEquals("branch: Created from rr/renamebranchv4", e.getComment());
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.ReflogEntry

  public void testReadWhileAppendIsInProgress() throws Exception {
    setupReflog("logs/refs/heads/master", twoLineWithAppendInProgress);
    ReflogReader reader = new ReflogReaderImpl(db, "refs/heads/master");
    List<ReflogEntry> reverseEntries = reader.getReverseEntries();
    assertEquals(2, reverseEntries.size());
    ReflogEntry e = reverseEntries.get(0);
    assertEquals(ObjectId
        .fromString("c6734895958052a9dbc396cff4459dc1a25029ab"), e
        .getOldId());
    assertEquals(ObjectId
        .fromString("54794942a18a237c57a80719afed44bb78172b10"), e
        .getNewId());
    assertEquals("Same A U Thor", e.getWho().getName());
    assertEquals("same.author@example.com", e.getWho().getEmailAddress());
    assertEquals(60, e.getWho().getTimeZoneOffset());
    assertEquals("2009-05-22T22:36:42", iso(e.getWho()));
    assertEquals(
        "rebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d",
        e.getComment());
    // while similar to testReadTwoLine, we can assume that if we get the last entry
    // right, everything else is too
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.ReflogEntry

  @Test
  public void testReadLineWithMissingComment() throws Exception {
    setupReflog("logs/refs/heads/master", oneLineWithoutComment);
    final ReflogReader reader = db.getReflogReader("master");
    ReflogEntry e = reader.getLastEntry();
    assertEquals(ObjectId
        .fromString("da85355dfc525c9f6f3927b876f379f46ccf826e"), e
        .getOldId());
    assertEquals(ObjectId
        .fromString("3e7549db262d1e836d9bf0af7e22355468f1717c"), e
        .getNewId());
    assertEquals("A O Thor Too", e.getWho().getName());
    assertEquals("authortoo@wri.tr", e.getWho().getEmailAddress());
    assertEquals(120, e.getWho().getTimeZoneOffset());
    assertEquals("2009-05-22T23:36:40", iso(e.getWho()));
    assertEquals("",
        e.getComment());
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.ReflogEntry

  public void testCheckout() throws Exception {
    setupReflog("logs/HEAD", switchBranch);
    List<ReflogEntry> entries = db.getReflogReader(Constants.HEAD)
        .getReverseEntries();
    assertEquals(1, entries.size());
    ReflogEntry entry = entries.get(0);
    CheckoutEntry checkout = entry.parseCheckout();
    assertNotNull(checkout);
    assertEquals("master", checkout.getToBranch());
    assertEquals("new/work", checkout.getFromBranch());
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.ReflogEntry

  @Test
  public void testSpecificEntryNumber() throws Exception {
    setupReflog("logs/refs/heads/master", twoLine);

    ReflogReader reader = new ReflogReaderImpl(db, "refs/heads/master");
    ReflogEntry e = reader.getReverseEntry(0);
    assertEquals(
        ObjectId.fromString("c6734895958052a9dbc396cff4459dc1a25029ab"),
        e.getOldId());
    assertEquals(
        ObjectId.fromString("54794942a18a237c57a80719afed44bb78172b10"),
        e.getNewId());
    assertEquals("Same A U Thor", e.getWho().getName());
    assertEquals("same.author@example.com", e.getWho().getEmailAddress());
    assertEquals(60, e.getWho().getTimeZoneOffset());
    assertEquals("2009-05-22T22:36:42", iso(e.getWho()));
    assertEquals(
        "rebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d",
        e.getComment());

    e = reader.getReverseEntry(1);
    assertEquals(
        ObjectId.fromString("0000000000000000000000000000000000000000"),
        e.getOldId());
    assertEquals(
        ObjectId.fromString("c6734895958052a9dbc396cff4459dc1a25029ab"),
        e.getNewId());
    assertEquals("A U Thor", e.getWho().getName());
    assertEquals("thor@committer.au", e.getWho().getEmailAddress());
    assertEquals(-60, e.getWho().getTimeZoneOffset());
    assertEquals("2009-05-22T20:36:41", iso(e.getWho()));
    assertEquals("branch: Created from rr/renamebranchv4", e.getComment());

    assertNull(reader.getReverseEntry(3));
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.ReflogEntry

    entries.remove(stashRefEntry);
    ObjectId entryId = ObjectId.zeroId();
    try {
      for (int i = entries.size() - 1; i >= 0; i--) {
        ReflogEntry entry = entries.get(i);
        writer.log(stashLockRef, entryId, entry.getNewId(),
            entry.getWho(), entry.getComment());
        entryId = entry.getNewId();
      }
      if (!stashLockFile.renameTo(stashFile)) {
        FileUtils.delete(stashFile);
        if (!stashLockFile.renameTo(stashFile))
          throw new JGitInternalException(MessageFormat.format(
View Full Code Here

Examples of org.eclipse.jgit.lib.ReflogEntry

    fsck(remoteRepository, Q);

    final ReflogReader log = remoteRepository.getReflogReader(dstName);
    assertNotNull("has log for " + dstName);

    final ReflogEntry last = log.getLastEntry();
    assertNotNull("has last entry", last);
    assertEquals(ObjectId.zeroId(), last.getOldId());
    assertEquals(Q, last.getNewId());
    assertEquals("anonymous", last.getWho().getName());

    // Assumption: The host name we use to contact the server should
    // be the server's own host name, because it should be the loopback
    // network interface.
    //
    final String clientHost = remoteURI.getHost();
    assertEquals("anonymous@" + clientHost, last.getWho().getEmailAddress());
    assertEquals("push: created", last.getComment());

    List<AccessEvent> requests = getRequests();
    assertEquals(2, requests.size());

    AccessEvent info = requests.get(0);
View Full Code Here

Examples of org.eclipse.jgit.lib.ReflogEntry

   * @return commit selected in Reflog View
   * @throws ExecutionException
   */
  protected RevCommit getSelectedCommit(ExecutionEvent event, Repository repo)
      throws ExecutionException {
    ReflogEntry entry = (ReflogEntry) ((IStructuredSelection) HandlerUtil
        .getCurrentSelectionChecked(event)).getFirstElement();
    if (entry == null)
      return null;

    RevCommit commit = null;
    RevWalk w = new RevWalk(repo);
    try {
      commit = w.parseCommit(entry.getNewId());
    } catch (IOException e) {
      throw new ExecutionException(e.getMessage(), e);
    } finally {
      w.release();
    }
View Full Code Here

Examples of org.eclipse.jgit.lib.ReflogEntry

        UIText.ReflogView_CommitColumnHeader, 10, SWT.LEFT);
    toColumn.setLabelProvider(new ColumnLabelProvider() {

      @Override
      public String getText(Object element) {
        final ReflogEntry entry = (ReflogEntry) element;
        return entry.getNewId().abbreviate(7).name();
      }

      @Override
      public String getToolTipText(Object element) {
        final ReflogEntry entry = (ReflogEntry) element;
        return entry.getNewId().name();
      }

      @Override
      public Image getImage(Object element) {
        return branchImage;
      }

    });

    TreeViewerColumn commitMessageColumn = createColumn(layout,
        UIText.ReflogView_CommitMessageColumnHeader, 40, SWT.LEFT);
    commitMessageColumn.setLabelProvider(new ColumnLabelProvider() {

      @Override
      public String getText(Object element) {
        final ReflogEntry entry = (ReflogEntry) element;
        RevCommit c = getCommit(entry);
        return c == null ? "" : c.getShortMessage(); //$NON-NLS-1$
      }

      private RevCommit getCommit(final ReflogEntry entry) {
        RevWalk walk = new RevWalk(getRepository());
        walk.setRetainBody(true);
        RevCommit c = null;
        try {
          c = walk.parseCommit(entry.getNewId());
        } catch (IOException ignored) {
          // ignore
        } finally {
          walk.release();
        }
        return c;
      }
    });

    TreeViewerColumn dateColumn = createColumn(layout,
        UIText.ReflogView_DateColumnHeader, 15, SWT.LEFT);
    dateColumn.setLabelProvider(new ColumnLabelProvider() {

      @Override
      public String getText(Object element) {
        final ReflogEntry entry = (ReflogEntry) element;
        final PersonIdent who = entry.getWho();
        // TODO add option to use RelativeDateFormatter
        return absoluteFormatter.format(who.getWhen());
      }

      @Override
      public Image getImage(Object element) {
        return null;
      }

    });

    TreeViewerColumn messageColumn = createColumn(layout,
        UIText.ReflogView_MessageColumnHeader, 40, SWT.LEFT);
    messageColumn.setLabelProvider(new ColumnLabelProvider() {

      private ResourceManager resourceManager = new LocalResourceManager(
          JFaceResources.getResources());

      @Override
      public String getText(Object element) {
        final ReflogEntry entry = (ReflogEntry) element;
        return entry.getComment();
      }

      public Image getImage(Object element) {
        String comment = ((ReflogEntry) element).getComment();
        if (comment.startsWith("commit:") || comment.startsWith("commit (initial):")) //$NON-NLS-1$ //$NON-NLS-2$
          return (Image) resourceManager.get(UIIcons.COMMIT);
        if (comment.startsWith("commit (amend):")) //$NON-NLS-1$
          return (Image) resourceManager.get(UIIcons.AMEND_COMMIT);
        if (comment.startsWith("pull")) //$NON-NLS-1$
          return (Image) resourceManager.get(UIIcons.PULL);
        if (comment.startsWith("clone")) //$NON-NLS-1$
          return (Image) resourceManager.get(UIIcons.CLONEGIT);
        if (comment.startsWith("rebase")) //$NON-NLS-1$
          return (Image) resourceManager.get(UIIcons.REBASE);
        if (comment.startsWith("merge")) //$NON-NLS-1$
          return (Image) resourceManager.get(UIIcons.MERGE);
        if (comment.startsWith("fetch")) //$NON-NLS-1$
          return (Image) resourceManager.get(UIIcons.FETCH);
        if (comment.startsWith("branch")) //$NON-NLS-1$
          return (Image) resourceManager.get(UIIcons.CREATE_BRANCH);
        if (comment.startsWith("checkout")) //$NON-NLS-1$
          return (Image) resourceManager.get(UIIcons.CHECKOUT);
        return null;
      }

      public void dispose() {
        resourceManager.dispose();
        super.dispose();
      }
    });

    new OpenAndLinkWithEditorHelper(refLogTableTreeViewer) {
      @Override
      protected void linkToEditor(ISelection selection) {
        // Not supported

      }
      @Override
      protected void open(ISelection sel, boolean activate) {
        handleOpen(sel, OpenStrategy.activateOnOpen());
      }
      @Override
      protected void activate(ISelection selection) {
        handleOpen(selection, true);
      }
      private void handleOpen(ISelection selection, boolean activateOnOpen) {
        if (selection instanceof IStructuredSelection)
          if (selection.isEmpty())
            return;
        Repository repo = getRepository();
        if (repo == null)
          return;
        RevWalk walk = new RevWalk(repo);
        try {
          for (Object element : ((IStructuredSelection)selection).toArray()) {
            ReflogEntry entry = (ReflogEntry) element;
            ObjectId id = entry.getNewId();
            if (id == null || id.equals(ObjectId.zeroId()))
              id = entry.getOldId();
            if (id != null && !id.equals(ObjectId.zeroId()))
              CommitEditor.openQuiet(new RepositoryCommit(repo,
                  walk.parseCommit(id)), activateOnOpen);
          }
        } catch (IOException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.