Skip to contentSkip to conversation

Add a POM file for setting JGit library as a Maven project

PATCH New [email protected] 1 participant 4 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 Add a POM file for setting JGit library as a Maven project

From: Imran M Yousuf <[email protected]>

---
 jgit-maven/jgit/pom.xml |  169 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 169 insertions(+), 0 deletions(-)
 create mode 100644 jgit-maven/jgit/pom.xml
jgit-maven/jgit/pom.xml new file +169 -0
new file mode 100644
index 0000000..c4d7c24
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+All rights reserved.
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following
+conditions are met:
+
+Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following
+disclaimer in the documentation and/or other materials provided
+with the distribution.
+
+Neither the name of the Git Development Community nor the
+names of its contributors may be used to endorse or promote
+products derived from this software without specific prior
+written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" 
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.spearce</groupId>
+    <artifactId>jgit</artifactId>
+    <packaging>jar</packaging>
+    <version>0.4-SNAPSHOT</version>
+    <name>jgit</name>
+    <url>http://repo.or.cz/w/egit.git</url>
+    <mailingLists>
+        <mailingList>
+            <name>GIT Mailing List</name>
+            <post>[email protected]</post>
+            <archive>http://marc.info/?l=git</archive>
+        </mailingList>
+    </mailingLists>
+    <description>Pure Java implementation of Git</description>
+    <developers>
+        <developer>
+            <name>Shawn O. Pearce</name>
+            <email>[email protected]</email>
+            <roles>
+                <role>Maintainer</role>
+            </roles>
+        </developer>
+        <developer>
+            <name>Robin Rosenberg</name>
+            <email>[email protected]</email>
+            <roles>
+                <role>Maintainer</role>
+            </roles>
+        </developer>
+        <developer>
+            <name>Dave Watson</name>
+            <email>[email protected]</email>
+            <roles>
+                <role>Developer</role>
+            </roles>
+        </developer>
+        <developer>
+            <name>Roger C. Soares</name>
+            <email>[email protected]</email>
+            <roles>
+                <role>Developer</role>
+            </roles>
+	</developer>
+	<developer>
+            <name>Marek Zawirski</name>
+            <email>[email protected]</email>
+            <roles>
+                <role>Developer</role>
+            </roles>
+        </developer>
+        <developer>
+            <name>Imran M Yousuf</name>
+            <email>[email protected]</email>
+            <organization>Smart IT Engineering</organization>
+            <roles>
+                <role>Contributor</role>
+            </roles>
+        </developer>
+    </developers>
+    <licenses>
+        <license>
+            <name>3-clause (new-style) BSD license.</name>
+            <comments>
+                All rights reserved.
+                Redistribution and use in source and binary forms, with or
+                without modification, are permitted provided that the following
+                conditions are met:
+
+                Redistributions of source code must retain the above copyright
+                notice, this list of conditions and the following disclaimer.
+
+                Redistributions in binary form must reproduce the above
+                copyright notice, this list of conditions and the following
+                disclaimer in the documentation and/or other materials provided
+                with the distribution.
+
+                Neither the name of the Git Development Community nor the
+                names of its contributors may be used to endorse or promote
+                products derived from this software without specific prior
+                written permission.
+
+                THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+                CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+                INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+                OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+                ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+                CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+                SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+                NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+                LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+                CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+                STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+                ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+            </comments>
+        </license>
+    </licenses>
+    <build>
+        <sourceDirectory>../../org.spearce.jgit/src/</sourceDirectory>
+        <testResources>
+            <testResource>
+                <directory>../../org.spearce.jgit.test/tst-rsrc/</directory>
+            </testResource>
+        </testResources>
+        <testSourceDirectory>../../org.spearce.jgit.test/tst/</testSourceDirectory>
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.0.2</version>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.jcraft</groupId>
+            <artifactId>jsch</artifactId>
+            <version>0.1.38</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+</project>
Signature · 1 line
1.5.6
#2 lore raw

PATCH 3/6 Add test resources directory as a classpath entry

In reply to a message not in the archive

From: Imran M Yousuf <[email protected]>

Since test resources will be required to be read from classpath thus adding record to Eclipse's .classpath setting file.

---
 org.spearce.jgit.test/.classpath |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
org.spearce.jgit.test/.classpath +1 -0
index 592fa17..a276507 100644
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry excluding="**/*.idx|**/*.pack" kind="src" path="tst"/>
+	<classpathentry kind="src" path="tst-rsrc"/>
 	<classpathentry kind="src" path="exttst"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/org.spearce.jgit"/>
Signature · 1 line
1.5.6
#3 lore raw

PATCH 4/6 Use test resources from classpath

From: Imran M Yousuf <[email protected]>

Searched and fixed usage of resources, all tests are now passing and using classpath resources.

A utility class for test classes are created. One of its operation turns classpath resources to File and it is used by all test classes to locate test resources.

---
 .../dircache/DirCacheCGitCompatabilityTest.java    |    3 +-
 .../tst/org/spearce/jgit/lib/PackIndexV1Test.java  |    9 ++-
 .../tst/org/spearce/jgit/lib/PackIndexV2Test.java  |    5 +-
 .../org/spearce/jgit/lib/PackReverseIndexTest.java |    5 +-
 .../tst/org/spearce/jgit/lib/PackWriterTest.java   |    3 +-
 .../org/spearce/jgit/lib/RepositoryTestCase.java   |    7 +-
 .../org/spearce/jgit/transport/IndexPackTest.java  |    6 +-
 .../tst/org/spearce/jgit/util/JGitTestUtil.java    |   63 ++++++++++++++++++++
 8 files changed, 84 insertions(+), 17 deletions(-)
 create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
org.spearce.jgit.test/tst/org/spearce/jgit/dircache/DirCacheCGitCompatabilityTest.java +2 -1
index 43b23f6..b052686 100644
@@ -50,6 +50,7 @@
 import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.lib.RepositoryTestCase;
 import org.spearce.jgit.treewalk.TreeWalk;
+import org.spearce.jgit.util.JGitTestUtil;
 
 public class DirCacheCGitCompatabilityTest extends RepositoryTestCase {
 	private final File index = pathOf("gitgit.index");
@@ -138,7 +139,7 @@ assertEquals(ObjectId
 	}
 
 	private File pathOf(final String name) {
-		return new File("tst", name);
+		return JGitTestUtil.getTestResourceFile(name);
 	}
 
 	private Map<String, CGitIndexRecord> readLsFiles() throws Exception {
org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV1Test.java +5 -4
index 49235ca..645e054 100644
@@ -40,18 +40,19 @@
 import java.io.File;
 
 import org.spearce.jgit.errors.MissingObjectException;
+import org.spearce.jgit.util.JGitTestUtil;
 
 public class PackIndexV1Test extends PackIndexTest {
 	@Override
 	public File getFileForPack34be9032() {
-		return new File(new File("tst"),
-				"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idx");
+		return JGitTestUtil.getTestResourceFile(
+                    "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idx");
 	}
 
 	@Override
 	public File getFileForPackdf2982f28() {
-		return new File(new File("tst"),
-				"pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.idx");
+		return JGitTestUtil.getTestResourceFile(
+                    "pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.idx");
 	}
 
 	/**
org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV2Test.java +3 -2
index c986c49..d95937c 100644
@@ -40,17 +40,18 @@
 import java.io.File;
 
 import org.spearce.jgit.errors.MissingObjectException;
+import org.spearce.jgit.util.JGitTestUtil;
 
 public class PackIndexV2Test extends PackIndexTest {
 	@Override
 	public File getFileForPack34be9032() {
-		return new File(new File("tst"),
+		return JGitTestUtil.getTestResourceFile(
 				"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idxV2");
 	}
 
 	@Override
 	public File getFileForPackdf2982f28() {
-		return new File(new File("tst"),
+		return JGitTestUtil.getTestResourceFile(
 				"pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.idxV2");
 	}
 
org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackReverseIndexTest.java +2 -3
index 52d1282..c66818f 100644
@@ -37,10 +37,9 @@
 
 package org.spearce.jgit.lib;
 
-import java.io.File;
-
 import org.spearce.jgit.errors.CorruptObjectException;
 import org.spearce.jgit.lib.PackIndex.MutableEntry;
+import org.spearce.jgit.util.JGitTestUtil;
 
 public class PackReverseIndexTest extends RepositoryTestCase {
 
@@ -54,7 +53,7 @@
 	public void setUp() throws Exception {
 		super.setUp();
 		// index with both small (< 2^31) and big offsets
-		idx = PackIndex.open(new File(new File("tst"),
+		idx = PackIndex.open(JGitTestUtil.getTestResourceFile(
 				"pack-huge.idx"));
 		reverseIdx = new PackReverseIndex(idx);
 	}
org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java +2 -1
index 4dd4b2a..87ec091 100644
@@ -57,6 +57,7 @@
 import org.spearce.jgit.revwalk.RevWalk;
 import org.spearce.jgit.transport.IndexPack;
 import org.spearce.jgit.util.CountingOutputStream;
+import org.spearce.jgit.util.JGitTestUtil;
 
 public class PackWriterTest extends RepositoryTestCase {
 
@@ -239,7 +240,7 @@ public void testWritePack2DeltasCRC32Copy() throws IOException {
 				"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack");
 		final File crc32Idx = new File(packDir,
 				"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idx");
-		copyFile(new File(new File("tst"),
+		copyFile(JGitTestUtil.getTestResourceFile(
 				"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idxV2"),
 				crc32Idx);
 		db.openPack(crc32Pack, crc32Idx);
org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java +4 -3
index 14e7179..310690a 100644
@@ -47,6 +47,7 @@
 import java.io.Reader;
 
 import junit.framework.TestCase;
+import org.spearce.jgit.util.JGitTestUtil;
 
 public abstract class RepositoryTestCase extends TestCase {
 
@@ -145,13 +146,13 @@ public void run() {
 		final File tst = new File("tst");
 		final File packDir = new File(db.getObjectsDirectory(), "pack");
 		for (int k = 0; k < packs.length; k++) {
-			copyFile(new File(tst, packs[k] + ".pack"), new File(packDir,
+			copyFile(JGitTestUtil.getTestResourceFile(packs[k] + ".pack"), new File(packDir,
 					packs[k] + ".pack"));
-			copyFile(new File(tst, packs[k] + ".idx"), new File(packDir,
+			copyFile(JGitTestUtil.getTestResourceFile(packs[k] + ".idx"), new File(packDir,
 					packs[k] + ".idx"));
 		}
 
-		copyFile(new File(tst, "packed-refs"), new File(trash_git,"packed-refs"));
+		copyFile(JGitTestUtil.getTestResourceFile("packed-refs"), new File(trash_git,"packed-refs"));
 
 		db.scanForPacks();
 	}
org.spearce.jgit.test/tst/org/spearce/jgit/transport/IndexPackTest.java +3 -3
index ffa9142..46bd969 100644
@@ -47,7 +47,7 @@
 import org.spearce.jgit.lib.PackFile;
 import org.spearce.jgit.lib.RepositoryTestCase;
 import org.spearce.jgit.lib.TextProgressMonitor;
-import org.spearce.jgit.transport.IndexPack;
+import org.spearce.jgit.util.JGitTestUtil;
 
 /**
  * Test indexing of git packs. A pack is read from a stream, copied
@@ -63,7 +63,7 @@
 	 * @throws IOException
 	 */
 	public void test1() throws  IOException {
-		File packFile = new File("tst/pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack");
+		File packFile = JGitTestUtil.getTestResourceFile("pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack");
 		final InputStream is = new FileInputStream(packFile);
 		try {
 			IndexPack pack = new IndexPack(db, is, new File(trash, "tmp_pack1"));
@@ -89,7 +89,7 @@ public void test1() throws  IOException {
 	 * @throws IOException
 	 */
 	public void test2() throws  IOException {
-		File packFile = new File("tst/pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.pack");
+		File packFile = JGitTestUtil.getTestResourceFile("pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.pack");
 		final InputStream is = new FileInputStream(packFile);
 		try {
 			IndexPack pack = new IndexPack(db, is, new File(trash, "tmp_pack2"));
org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
1.5.6
#4 lore raw

PATCH 5/6 Add script for adding second pack for test purpose

From: Imran M Yousuf <[email protected]>

Forgot to add it last time and thus adding it before removing duplicate resources.

---
 .../spearce/jgit/test/resources/create-second-pack |  136 ++++++++++++++++++++
 1 files changed, 136 insertions(+), 0 deletions(-)
 create mode 100755 org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack
org.spearce.jgit.test/tst-rsrc/org/spearce/jgit/test/resources/create-second-pack new file +136 -0
new file mode 100755
index 0000000..03f83dc
@@ -0,0 +1,136 @@
+#!/bin/bash -ex
+
+export GIT_COMMITTER_NAME="A U Thor"
+export GIT_AUTHOR_NAME="A U Thor"
+export GIT_COMMITTER_EMAIL="[email protected]"
+export GIT_AUTHOR_EMAIL="[email protected]"
+
+test_tick () {
+	# from git/t/test-lib.sh
+	if test -z "${test_tick+set}"
+        then
+                test_tick=1112911993
+        else
+                test_tick=$(($test_tick + 60))
+        fi
+        GIT_COMMITTER_DATE="$test_tick -0700"
+        GIT_AUTHOR_DATE="$test_tick -0700"
+        export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
+}
+
+git_commit () {
+	test_tick
+	git commit "$@"
+}
+
+git_merge () {
+	test_tick
+	git merge "$@"
+
+}
+
+test_tick
+rm -rf .git *.txt ?
+git init
+echo "On master" >>master.txt
+git add master.txt
+git_commit -a -m "On master"
+
+echo "On master" >>master.txt
+git_commit -a -m "On master again"
+
+git checkout -b a 6c8b137b1c652731597c89668f417b8695f28dd7
+mkdir a
+
+echo a1 >>a/a1.txt
+git add a/a1.txt
+git_commit -a -m "First a/a1"
+
+echo a2 >>a/a2.txt
+git add a/a2.txt
+git_commit -a -m "First a/a2"
+
+git merge master
+
+echo a1 >>a/a1.txt
+git add a/a1.txt
+git_commit -a -m "Second a/a1"
+git branch pa
+
+echo a2 >>a/a2.txt
+git add a/a2.txt
+git_commit -a -m "Second a/a2"
+
+git checkout -b b 58be4659bb571194ed4562d04b359d26216f526e
+
+mkdir b
+echo b1 >>b/b1.txt
+git add b/b1.txt
+git_commit -a -m "First b/b1"
+
+echo b2 >>b/b2.txt
+git add b/b2.txt
+git_commit -a -m "First b/b2"
+
+git merge a
+
+echo b1 >>b/b1.txt
+git add b/b1.txt
+git_commit -a -m "Second b/b1"
+
+echo b2 >>b/b2.txt
+git add b/b2.txt
+git_commit -a -m "Second b/b2"
+
+rm -rf a b c master.txt
+mkdir c
+rm -f ./git/index
+echo ref: refs/heads/c >.git/HEAD
+
+echo c1 >>c/c1.txt
+git add c/c1.txt
+git_commit -a -m "First c/c1, no parent"
+
+echo c2 >>c/c2.txt
+git add c/c2.txt
+git_commit -a -m "First c/c2"
+
+git_merge a
+
+echo c1 >>c/c1.txt
+git add c/c2.txt
+git_commit -a -m "Second c/c1"
+
+echo c2 >>c/c2.txt
+git add c/c2.txt
+git_commit -a -m "Second c/c2"
+
+git_merge b
+
+git checkout -b d a
+
+echo "a1" >>a/a1
+git add a/a1
+git_commit -a -m "Third a/a1"
+
+git checkout -b e a
+
+echo "a1" >>a/a1
+git add a/a1
+git_commit -a -m "Fourth a/a1"
+
+git checkout master
+
+git_merge c d e
+
+git repack -d
+
+git tag A a
+git tag -a -m "An annotated tag" B a^
+
+git repack -d
+
+git pack-refs --all
+
+
+qgit --all master
Signature · 1 line
1.5.6