View Javadoc
1   /*
2    * Copyright (C) 2022, Matthias Sohn <matthias.sohn@sap.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  
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 LogTest extends CLIRepositoryTestCase {
20  
21  	@Before
22  	public void setup() throws Exception {
23  		writeTrashFile("a", "a");
24  		writeTrashFile("b", "a");
25  		execute("git add a b");
26  		execute("git commit -m added");
27  	}
28  
29  	@Test
30  	public void testLogCommitNewFile() throws Exception {
31  		String result = toString(execute("git log"));
32  		assertEquals(
33  				toString("commit b4680f542095a8b41ea4258a5c03b548543a817c",
34  						"Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>",
35  						"Date:   Sat Aug 15 20:12:58 2009 -0330", "added"),
36  				result);
37  	}
38  
39  	@Test
40  	public void testLogNameOnly() throws Exception {
41  		String result = toString(execute("git log --name-only"));
42  		assertEquals(
43  				toString("commit b4680f542095a8b41ea4258a5c03b548543a817c",
44  						"Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>",
45  						"Date:   Sat Aug 15 20:12:58 2009 -0330", "added", "a",
46  						"b"),
47  				result);
48  	}
49  
50  	@Test
51  	public void testDiffCommitModifiedFileNameStatus() throws Exception {
52  		String result = toString(execute("git log --name-status"));
53  		assertEquals(toString("commit b4680f542095a8b41ea4258a5c03b548543a817c",
54  				"Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>",
55  				"Date:   Sat Aug 15 20:12:58 2009 -0330", "added", "A\ta",
56  				"A\tb"),
57  				result);
58  	}
59  }