diff options
Diffstat (limited to 'org.eclipse.jgit.pgm.test')
5 files changed, 211 insertions, 21 deletions
diff --git a/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF index cd947f00f6..0bdc4084d7 100644 --- a/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF @@ -3,30 +3,30 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Automatic-Module-Name: org.eclipse.jgit.pgm.test Bundle-SymbolicName: org.eclipse.jgit.pgm.test -Bundle-Version: 6.3.1.qualifier +Bundle-Version: 6.4.1.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-11 -Import-Package: org.eclipse.jgit.api;version="[6.3.1,6.4.0)", - org.eclipse.jgit.api.errors;version="[6.3.1,6.4.0)", - org.eclipse.jgit.diff;version="[6.3.1,6.4.0)", - org.eclipse.jgit.dircache;version="[6.3.1,6.4.0)", - org.eclipse.jgit.internal.diffmergetool;version="6.3.1", - org.eclipse.jgit.internal.storage.file;version="6.3.1", - org.eclipse.jgit.junit;version="[6.3.1,6.4.0)", - org.eclipse.jgit.lib;version="[6.3.1,6.4.0)", - org.eclipse.jgit.lib.internal;version="[6.3.1,6.4.0)", - org.eclipse.jgit.merge;version="[6.3.1,6.4.0)", - org.eclipse.jgit.pgm;version="[6.3.1,6.4.0)", - org.eclipse.jgit.pgm.internal;version="[6.3.1,6.4.0)", - org.eclipse.jgit.pgm.opt;version="[6.3.1,6.4.0)", - org.eclipse.jgit.revwalk;version="[6.3.1,6.4.0)", - org.eclipse.jgit.storage.file;version="[6.3.1,6.4.0)", - org.eclipse.jgit.transport;version="[6.3.1,6.4.0)", - org.eclipse.jgit.treewalk;version="[6.3.1,6.4.0)", - org.eclipse.jgit.util;version="[6.3.1,6.4.0)", - org.eclipse.jgit.util.io;version="[6.3.1,6.4.0)", +Import-Package: org.eclipse.jgit.api;version="[6.4.1,6.5.0)", + org.eclipse.jgit.api.errors;version="[6.4.1,6.5.0)", + org.eclipse.jgit.diff;version="[6.4.1,6.5.0)", + org.eclipse.jgit.dircache;version="[6.4.1,6.5.0)", + org.eclipse.jgit.internal.diffmergetool;version="6.4.1", + org.eclipse.jgit.internal.storage.file;version="6.4.1", + org.eclipse.jgit.junit;version="[6.4.1,6.5.0)", + org.eclipse.jgit.lib;version="[6.4.1,6.5.0)", + org.eclipse.jgit.lib.internal;version="[6.4.1,6.5.0)", + org.eclipse.jgit.merge;version="[6.4.1,6.5.0)", + org.eclipse.jgit.pgm;version="[6.4.1,6.5.0)", + org.eclipse.jgit.pgm.internal;version="[6.4.1,6.5.0)", + org.eclipse.jgit.pgm.opt;version="[6.4.1,6.5.0)", + org.eclipse.jgit.revwalk;version="[6.4.1,6.5.0)", + org.eclipse.jgit.storage.file;version="[6.4.1,6.5.0)", + org.eclipse.jgit.transport;version="[6.4.1,6.5.0)", + org.eclipse.jgit.treewalk;version="[6.4.1,6.5.0)", + org.eclipse.jgit.util;version="[6.4.1,6.5.0)", + org.eclipse.jgit.util.io;version="[6.4.1,6.5.0)", org.hamcrest.core;bundle-version="[1.1.0,3.0.0)", org.junit;version="[4.13,5.0.0)", org.junit.rules;version="[4.13,5.0.0)", diff --git a/org.eclipse.jgit.pgm.test/pom.xml b/org.eclipse.jgit.pgm.test/pom.xml index fd87d922e7..dad92886af 100644 --- a/org.eclipse.jgit.pgm.test/pom.xml +++ b/org.eclipse.jgit.pgm.test/pom.xml @@ -17,7 +17,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>6.3.1-SNAPSHOT</version> + <version>6.4.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.pgm.test</artifactId> diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffTest.java new file mode 100644 index 0000000000..859b54de4d --- /dev/null +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2022, Matthias Sohn <matthias.sohn@sap.com> and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.eclipse.jgit.pgm; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.jgit.lib.CLIRepositoryTestCase; +import org.junit.Before; +import org.junit.Test; + +public class DiffTest extends CLIRepositoryTestCase { + + private static final String NO_NEWLINE = "\\ No newline at end of file"; + + @Before + public void setup() throws Exception { + writeTrashFile("a", "a"); + execute("git add a"); + execute("git commit -m added"); + } + + @Test + public void testDiffCommitNewFile() throws Exception { + writeTrashFile("a1", "a"); + String result = toString(execute("git diff")); + assertEquals( + toString("diff --git a/a1 b/a1", "new file mode 100644", + "index 0000000..2e65efe", "--- /dev/null", "+++ b/a1", + "@@ -0,0 +1 @@", "+a", NO_NEWLINE), + result); + } + + @Test + public void testDiffCommitModifiedFile() throws Exception { + writeTrashFile("a", "a1"); + String result = toString(execute("git diff")); + assertEquals( + toString("diff --git a/a b/a", "index 2e65efe..59ef8d1 100644", + "--- a/a", "+++ b/a", "@@ -1 +1 @@", + "-a", NO_NEWLINE, "+a1", NO_NEWLINE), + result); + } + + @Test + public void testDiffCommitModifiedFileNameOnly() throws Exception { + writeTrashFile("a", "a1"); + writeTrashFile("b", "b"); + String result = toString(execute("git diff --name-only")); + assertEquals(toString("a", "b"), result); + } + + @Test + public void testDiffCommitModifiedFileNameStatus() throws Exception { + writeTrashFile("a", "a1"); + writeTrashFile("b", "b"); + String result = toString(execute("git diff --name-status")); + assertEquals(toString("M\ta", "A\tb"), result); + } +} diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/LogTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/LogTest.java new file mode 100644 index 0000000000..1cc52a44ac --- /dev/null +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/LogTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2022, Matthias Sohn <matthias.sohn@sap.com> and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.eclipse.jgit.pgm; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.jgit.lib.CLIRepositoryTestCase; +import org.junit.Before; +import org.junit.Test; + +public class LogTest extends CLIRepositoryTestCase { + + @Before + public void setup() throws Exception { + writeTrashFile("a", "a"); + writeTrashFile("b", "a"); + execute("git add a b"); + execute("git commit -m added"); + } + + @Test + public void testLogCommitNewFile() throws Exception { + String result = toString(execute("git log")); + assertEquals( + toString("commit b4680f542095a8b41ea4258a5c03b548543a817c", + "Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>", + "Date: Sat Aug 15 20:12:58 2009 -0330", "added"), + result); + } + + @Test + public void testLogNameOnly() throws Exception { + String result = toString(execute("git log --name-only")); + assertEquals( + toString("commit b4680f542095a8b41ea4258a5c03b548543a817c", + "Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>", + "Date: Sat Aug 15 20:12:58 2009 -0330", "added", "a", + "b"), + result); + } + + @Test + public void testDiffCommitModifiedFileNameStatus() throws Exception { + String result = toString(execute("git log --name-status")); + assertEquals(toString("commit b4680f542095a8b41ea4258a5c03b548543a817c", + "Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>", + "Date: Sat Aug 15 20:12:58 2009 -0330", "added", "A\ta", + "A\tb"), + result); + } +} diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ShowTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ShowTest.java new file mode 100644 index 0000000000..47d5d3433a --- /dev/null +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ShowTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2022, Matthias Sohn <matthias.sohn@sap.com> and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.eclipse.jgit.pgm; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.jgit.lib.CLIRepositoryTestCase; +import org.junit.Before; +import org.junit.Test; + +public class ShowTest extends CLIRepositoryTestCase { + + private static final String NO_NEWLINE = "\\ No newline at end of file"; + + @Before + public void setup() throws Exception { + writeTrashFile("a", "a"); + writeTrashFile("b", "b"); + execute("git add a b"); + execute("git commit -m added"); + writeTrashFile("a", "a1"); + execute("git add a"); + execute("git commit -m modified"); + } + + @Test + public void testShow() throws Exception { + String result = toString(execute("git show")); + assertEquals( + toString("commit ecdf62e777b7413fc463c20e935403d424410ab2", + "Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>", + "Date: Sat Aug 15 20:12:58 2009 -0330", "", + " modified", "", "diff --git a/a b/a", + "index 2e65efe..59ef8d1 100644", "--- a/a", "+++ b/a", + "@@ -1 +1 @@", "-a", NO_NEWLINE, "+a1", NO_NEWLINE), + result); + } + + @Test + public void testShowNameOnly() throws Exception { + String result = toString(execute("git show --name-only")); + assertEquals(toString("commit ecdf62e777b7413fc463c20e935403d424410ab2", + "Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>", + "Date: Sat Aug 15 20:12:58 2009 -0330", "", " modified", + "a"), result); + } + + @Test + public void testShowNameStatus() throws Exception { + String result = toString(execute("git show --name-status")); + assertEquals(toString("commit ecdf62e777b7413fc463c20e935403d424410ab2", + "Author: GIT_COMMITTER_NAME <GIT_COMMITTER_EMAIL>", + "Date: Sat Aug 15 20:12:58 2009 -0330", "", " modified", + "M\ta"), result); + } +} |