You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReflogTest.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (C) 2012, Tomasz Zarna <tomasz.zarna@tasktop.com> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.pgm;
  11. import static org.junit.Assert.assertArrayEquals;
  12. import static org.junit.Assert.assertEquals;
  13. import org.eclipse.jgit.api.Git;
  14. import org.eclipse.jgit.lib.CLIRepositoryTestCase;
  15. import org.junit.Test;
  16. public class ReflogTest extends CLIRepositoryTestCase {
  17. @Test
  18. public void testClean() throws Exception {
  19. assertArrayEquals(new String[] { "" }, execute("git reflog"));
  20. }
  21. @Test
  22. public void testSingleCommit() throws Exception {
  23. try (Git git = new Git(db)) {
  24. git.commit().setMessage("initial commit").call();
  25. assertEquals("6fd41be HEAD@{0}: commit (initial): initial commit",
  26. execute("git reflog")[0]);
  27. }
  28. }
  29. @Test
  30. public void testBranch() throws Exception {
  31. try (Git git = new Git(db)) {
  32. git.commit().setMessage("first commit").call();
  33. git.checkout().setCreateBranch(true).setName("side").call();
  34. writeTrashFile("file", "side content");
  35. git.add().addFilepattern("file").call();
  36. git.commit().setMessage("side commit").call();
  37. assertArrayEquals(new String[] {
  38. "38890c7 side@{0}: commit: side commit",
  39. "d216986 side@{1}: branch: Created from commit first commit",
  40. "" }, execute("git reflog refs/heads/side"));
  41. }
  42. }
  43. }