1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.pgm;
12
13 import static org.junit.Assert.assertEquals;
14
15 import org.eclipse.jgit.lib.CLIRepositoryTestCase;
16 import org.junit.Before;
17 import org.junit.Test;
18
19 public class ShowTest extends CLIRepositoryTestCase {
20
21 private static final String NO_NEWLINE = "\\ No newline at end of file";
22
23 @Before
24 public void setup() throws Exception {
25 writeTrashFile("a", "a");
26 writeTrashFile("b", "b");
27 execute("git add a b");
28 execute("git commit -m added");
29 writeTrashFile("a", "a1");
30 execute("git add a");
31 execute("git commit -m modified");
32 }
33
34 @Test
35 public void testShow() throws Exception {
36 String result = toString(execute("git show"));
37 assertEquals(
38 toString("commit ecdf62e777b7413fc463c20e935403d424410ab2",
39 "Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>",
40 "Date: Sat Aug 15 20:12:58 2009 -0330", "",
41 " modified", "", "diff --git a/a b/a",
42 "index 2e65efe..59ef8d1 100644", "--- a/a", "+++ b/a",
43 "@@ -1 +1 @@", "-a", NO_NEWLINE, "+a1", NO_NEWLINE),
44 result);
45 }
46
47 @Test
48 public void testShowNameOnly() throws Exception {
49 String result = toString(execute("git show --name-only"));
50 assertEquals(toString("commit ecdf62e777b7413fc463c20e935403d424410ab2",
51 "Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>",
52 "Date: Sat Aug 15 20:12:58 2009 -0330", "", " modified",
53 "a"), result);
54 }
55
56 @Test
57 public void testShowNameStatus() throws Exception {
58 String result = toString(execute("git show --name-status"));
59 assertEquals(toString("commit ecdf62e777b7413fc463c20e935403d424410ab2",
60 "Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>",
61 "Date: Sat Aug 15 20:12:58 2009 -0330", "", " modified",
62 "M\ta"), result);
63 }
64 }