1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.pgm;
11
12 import static org.junit.Assert.assertArrayEquals;
13 import static org.junit.Assert.assertEquals;
14
15 import org.eclipse.jgit.api.Git;
16 import org.eclipse.jgit.lib.CLIRepositoryTestCase;
17 import org.junit.Test;
18
19 public class ReflogTest extends CLIRepositoryTestCase {
20 @Test
21 public void testClean() throws Exception {
22 assertArrayEquals(new String[] { "" }, execute("git reflog"));
23 }
24
25 @Test
26 public void testSingleCommit() throws Exception {
27 try (Git git = new Git(db)) {
28 git.commit().setMessage("initial commit").call();
29
30 assertEquals("6fd41be HEAD@{0}: commit (initial): initial commit",
31 execute("git reflog")[0]);
32 }
33 }
34
35 @Test
36 public void testBranch() throws Exception {
37 try (Git git = new Git(db)) {
38 git.commit().setMessage("first commit").call();
39 git.checkout().setCreateBranch(true).setName("side").call();
40 writeTrashFile("file", "side content");
41 git.add().addFilepattern("file").call();
42 git.commit().setMessage("side commit").call();
43
44 assertArrayEquals(new String[] {
45 "38890c7 side@{0}: commit: side commit",
46 "d216986 side@{1}: branch: Created from commit first commit",
47 "" }, execute("git reflog refs/heads/side"));
48 }
49 }
50 }