Update JGit to org.eclipse.jgit 0.5.1.51-g96b2e76
Bug: issue 324 Change-Id: I434f70f76fe6139950a8686d23b04ecf442388e7 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
parent
f95d6459b1
commit
eaab2f3a46
|
@ -120,13 +120,13 @@ limitations under the License.
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse</groupId>
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
<artifactId>jgit</artifactId>
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse</groupId>
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
<artifactId>jgit</artifactId>
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<classifier>sources</classifier>
|
<classifier>sources</classifier>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
|
|
|
@ -33,7 +33,7 @@ import com.google.gerrit.httpd.GitWebConfig;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.util.NB;
|
import org.eclipse.jgit.util.IO;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -52,7 +52,7 @@ class GitLogoServlet extends HttpServlet {
|
||||||
GitLogoServlet(final GitWebConfig gitWebConfig) throws IOException {
|
GitLogoServlet(final GitWebConfig gitWebConfig) throws IOException {
|
||||||
byte[] png;
|
byte[] png;
|
||||||
try {
|
try {
|
||||||
png = NB.readFully(gitWebConfig.getGitLogoPNG());
|
png = IO.readFully(gitWebConfig.getGitLogoPNG());
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
png = null;
|
png = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import com.google.gwt.user.server.rpc.RPCServletUtils;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.util.NB;
|
import org.eclipse.jgit.util.IO;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -72,7 +72,7 @@ public class StaticServlet extends HttpServlet {
|
||||||
final FileInputStream in = new FileInputStream(p);
|
final FileInputStream in = new FileInputStream(p);
|
||||||
try {
|
try {
|
||||||
final byte[] r = new byte[(int) in.getChannel().size()];
|
final byte[] r = new byte[(int) in.getChannel().size()];
|
||||||
NB.readFully(in, r, 0, r.length);
|
IO.readFully(in, r, 0, r.length);
|
||||||
return r;
|
return r;
|
||||||
} finally {
|
} finally {
|
||||||
in.close();
|
in.close();
|
||||||
|
|
|
@ -34,8 +34,8 @@ limitations under the License.
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse</groupId>
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
<artifactId>jgit</artifactId>
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
package org.eclipse.jgit.lib;
|
package org.eclipse.jgit.lib;
|
||||||
|
|
||||||
import org.eclipse.jgit.util.NB;
|
import org.eclipse.jgit.util.IO;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -49,7 +49,7 @@ public class ObjectIdSerialization {
|
||||||
|
|
||||||
public static ObjectId readNotNull(final InputStream in) throws IOException {
|
public static ObjectId readNotNull(final InputStream in) throws IOException {
|
||||||
final byte[] b = new byte[20];
|
final byte[] b = new byte[20];
|
||||||
NB.readFully(in, b, 0, 20);
|
IO.readFully(in, b, 0, 20);
|
||||||
return ObjectId.fromRaw(b);
|
return ObjectId.fromRaw(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,13 @@ limitations under the License.
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse</groupId>
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
<artifactId>jgit</artifactId>
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
|
<artifactId>org.eclipse.jgit.junit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -37,9 +37,9 @@ import org.bouncycastle.openpgp.PGPPublicKey;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
||||||
import org.bouncycastle.openpgp.PGPUtil;
|
import org.bouncycastle.openpgp.PGPUtil;
|
||||||
|
import org.eclipse.jgit.util.IO;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.eclipse.jgit.util.NB;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -173,7 +173,7 @@ class EncryptedContactStore implements ContactStore {
|
||||||
final byte[] dst = new byte[2];
|
final byte[] dst = new byte[2];
|
||||||
final InputStream in = c.getInputStream();
|
final InputStream in = c.getInputStream();
|
||||||
try {
|
try {
|
||||||
NB.readFully(in, dst, 0, 2);
|
IO.readFully(in, dst, 0, 2);
|
||||||
} finally {
|
} finally {
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ package com.google.gerrit.server.ioutil;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.CodedEnum;
|
import com.google.gerrit.reviewdb.CodedEnum;
|
||||||
|
|
||||||
import org.eclipse.jgit.util.NB;
|
import org.eclipse.jgit.util.IO;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -116,7 +116,7 @@ public class BasicSerialization {
|
||||||
return NO_BYTES;
|
return NO_BYTES;
|
||||||
}
|
}
|
||||||
final byte[] buf = new byte[len];
|
final byte[] buf = new byte[len];
|
||||||
NB.readFully(input, buf, 0, len);
|
IO.readFully(input, buf, 0, len);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,11 @@ limitations under the License.
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
|
<artifactId>org.eclipse.jgit.junit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.sshd</groupId>
|
<groupId>org.apache.sshd</groupId>
|
||||||
<artifactId>sshd-core</artifactId>
|
<artifactId>sshd-core</artifactId>
|
||||||
|
|
|
@ -50,8 +50,7 @@
|
||||||
|
|
||||||
package com.google.gerrit.sshd.scproot.hooks;
|
package com.google.gerrit.sshd.scproot.hooks;
|
||||||
|
|
||||||
import com.google.gerrit.testutil.LocalDiskRepositoryTestCase;
|
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
|
@ -1,268 +0,0 @@
|
||||||
// Copyright (C) 2009, The Android Open Source Project
|
|
||||||
// Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
|
||||||
// Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
// Taken almost literally from JGit's test suite, as it does almost everything
|
|
||||||
// we need to create a local git repository for testing.
|
|
||||||
|
|
||||||
package com.google.gerrit.testutil;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.FileBasedConfig;
|
|
||||||
import org.eclipse.jgit.lib.PersonIdent;
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
|
||||||
import org.eclipse.jgit.lib.RepositoryCache;
|
|
||||||
import org.eclipse.jgit.util.NB;
|
|
||||||
import org.eclipse.jgit.util.SystemReader;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public abstract class LocalDiskRepositoryTestCase extends TestCase {
|
|
||||||
private static Thread shutdownHook;
|
|
||||||
private static int testCount;
|
|
||||||
|
|
||||||
protected PersonIdent author;
|
|
||||||
protected PersonIdent committer;
|
|
||||||
|
|
||||||
private final File trash = new File(new File("target"), "trash");
|
|
||||||
private final List<Repository> toClose = new ArrayList<Repository>();
|
|
||||||
private MockSystemReader mockSystemReader;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
if (shutdownHook == null) {
|
|
||||||
shutdownHook = new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
System.gc();
|
|
||||||
recursiveDelete("SHUTDOWN", trash, false, false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Runtime.getRuntime().addShutdownHook(shutdownHook);
|
|
||||||
}
|
|
||||||
|
|
||||||
recursiveDelete(testName(), trash, true, false);
|
|
||||||
|
|
||||||
mockSystemReader = new MockSystemReader();
|
|
||||||
mockSystemReader.userGitConfig =
|
|
||||||
new FileBasedConfig(new File(trash, "usergitconfig"));
|
|
||||||
SystemReader.setInstance(mockSystemReader);
|
|
||||||
|
|
||||||
final long now = mockSystemReader.getCurrentTime();
|
|
||||||
final int tz = mockSystemReader.getTimezone(now);
|
|
||||||
author = new PersonIdent("J. Author", "ja@example.com");
|
|
||||||
author = new PersonIdent(author, now, tz);
|
|
||||||
|
|
||||||
committer = new PersonIdent("J. Committer", "jc@example.com");
|
|
||||||
committer = new PersonIdent(committer, now, tz);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tearDown() throws Exception {
|
|
||||||
RepositoryCache.clear();
|
|
||||||
for (Repository r : toClose)
|
|
||||||
r.close();
|
|
||||||
toClose.clear();
|
|
||||||
|
|
||||||
recursiveDelete(testName(), trash, false, true);
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Increment the {@link #author} and {@link #committer} times. */
|
|
||||||
protected void tick() {
|
|
||||||
final long delta = TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES);
|
|
||||||
final long now = author.getWhen().getTime() + delta;
|
|
||||||
final int tz = mockSystemReader.getTimezone(now);
|
|
||||||
|
|
||||||
author = new PersonIdent(author, now, tz);
|
|
||||||
committer = new PersonIdent(committer, now, tz);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Recursively delete a directory, failing the test if the delete fails. */
|
|
||||||
protected void recursiveDelete(final File dir) {
|
|
||||||
recursiveDelete(testName(), dir, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean recursiveDelete(final String testName, final File dir,
|
|
||||||
boolean silent, boolean failOnError) {
|
|
||||||
assert !(silent && failOnError);
|
|
||||||
if (!dir.exists()) {
|
|
||||||
return silent;
|
|
||||||
}
|
|
||||||
final File[] ls = dir.listFiles();
|
|
||||||
if (ls != null) {
|
|
||||||
for (int k = 0; k < ls.length; k++) {
|
|
||||||
final File e = ls[k];
|
|
||||||
if (e.isDirectory()) {
|
|
||||||
silent = recursiveDelete(testName, e, silent, failOnError);
|
|
||||||
} else {
|
|
||||||
if (!e.delete()) {
|
|
||||||
if (!silent) {
|
|
||||||
reportDeleteFailure(testName, failOnError, e);
|
|
||||||
}
|
|
||||||
silent = !failOnError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!dir.delete()) {
|
|
||||||
if (!silent) {
|
|
||||||
reportDeleteFailure(testName, failOnError, dir);
|
|
||||||
}
|
|
||||||
silent = !failOnError;
|
|
||||||
}
|
|
||||||
return silent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void reportDeleteFailure(final String testName,
|
|
||||||
final boolean failOnError, final File e) {
|
|
||||||
final String severity;
|
|
||||||
if (failOnError)
|
|
||||||
severity = "ERROR";
|
|
||||||
else
|
|
||||||
severity = "WARNING";
|
|
||||||
|
|
||||||
final String msg = severity + ": Failed to delete " + e + " in " + testName;
|
|
||||||
if (failOnError)
|
|
||||||
fail(msg);
|
|
||||||
else
|
|
||||||
System.err.println(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Repository createWorkRepository() throws IOException {
|
|
||||||
return createRepository(false/* not bare */);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a new empty repository. */
|
|
||||||
private Repository createRepository(boolean bare) throws IOException {
|
|
||||||
final String uniqueId = System.currentTimeMillis() + "_" + (testCount++);
|
|
||||||
final String gitdirName = "test" + uniqueId + (bare ? "" : "/") + ".git";
|
|
||||||
final File gitdir = new File(trash, gitdirName).getCanonicalFile();
|
|
||||||
final Repository db = new Repository(gitdir);
|
|
||||||
|
|
||||||
assertFalse(gitdir.exists());
|
|
||||||
db.create();
|
|
||||||
toClose.add(db);
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Run a hook script in the repository, returning the exit status. */
|
|
||||||
protected int runHook(final Repository db, final File hook,
|
|
||||||
final String... args) throws IOException, InterruptedException {
|
|
||||||
final String[] argv = new String[1 + args.length];
|
|
||||||
argv[0] = hook.getAbsolutePath();
|
|
||||||
System.arraycopy(args, 0, argv, 1, args.length);
|
|
||||||
|
|
||||||
final Map<String, String> env = cloneEnv();
|
|
||||||
env.put("GIT_DIR", db.getDirectory().getAbsolutePath());
|
|
||||||
putPersonIdent(env, "AUTHOR", author);
|
|
||||||
putPersonIdent(env, "COMMITTER", committer);
|
|
||||||
|
|
||||||
final File cwd = db.getWorkDir();
|
|
||||||
final Process p = Runtime.getRuntime().exec(argv, toEnvArray(env), cwd);
|
|
||||||
p.getOutputStream().close();
|
|
||||||
p.getErrorStream().close();
|
|
||||||
p.getInputStream().close();
|
|
||||||
return p.waitFor();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void putPersonIdent(final Map<String, String> env,
|
|
||||||
final String type, final PersonIdent who) {
|
|
||||||
final String ident = who.toExternalString();
|
|
||||||
final String date = ident.substring(ident.indexOf("> ") + 2);
|
|
||||||
env.put("GIT_" + type + "_NAME", who.getName());
|
|
||||||
env.put("GIT_" + type + "_EMAIL", who.getEmailAddress());
|
|
||||||
env.put("GIT_" + type + "_DATE", date);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create a string to a UTF-8 temporary file and return the path. */
|
|
||||||
protected File write(final String body) throws IOException {
|
|
||||||
final File f = File.createTempFile("temp", "txt", trash);
|
|
||||||
try {
|
|
||||||
write(f, body);
|
|
||||||
return f;
|
|
||||||
} catch (Error e) {
|
|
||||||
f.delete();
|
|
||||||
throw e;
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
f.delete();
|
|
||||||
throw e;
|
|
||||||
} catch (IOException e) {
|
|
||||||
f.delete();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Write a string as a UTF-8 file. */
|
|
||||||
protected void write(final File f, final String body) throws IOException {
|
|
||||||
final Writer w = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
|
|
||||||
try {
|
|
||||||
w.write(body);
|
|
||||||
} finally {
|
|
||||||
w.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Fully read a UTF-8 file and return as a string. */
|
|
||||||
protected String read(final File f) throws IOException {
|
|
||||||
final byte[] body = NB.readFully(f);
|
|
||||||
return new String(body, 0, body.length, "UTF-8");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String[] toEnvArray(final Map<String, String> env) {
|
|
||||||
final String[] envp = new String[env.size()];
|
|
||||||
int i = 0;
|
|
||||||
for (Map.Entry<String, String> e : env.entrySet()) {
|
|
||||||
envp[i++] = e.getKey() + "=" + e.getValue();
|
|
||||||
}
|
|
||||||
return envp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static HashMap<String, String> cloneEnv() {
|
|
||||||
return new HashMap<String, String>(System.getenv());
|
|
||||||
}
|
|
||||||
|
|
||||||
private String testName() {
|
|
||||||
return getClass().getName() + "." + getName();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2009, Yann Simon <yann.simon.fr@gmail.com>
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.google.gerrit.testutil;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Constants;
|
|
||||||
import org.eclipse.jgit.lib.FileBasedConfig;
|
|
||||||
import org.eclipse.jgit.util.SystemReader;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
class MockSystemReader extends SystemReader {
|
|
||||||
final Map<String, String> values = new HashMap<String, String>();
|
|
||||||
|
|
||||||
FileBasedConfig userGitConfig;
|
|
||||||
|
|
||||||
MockSystemReader() {
|
|
||||||
init(Constants.OS_USER_NAME_KEY);
|
|
||||||
init(Constants.GIT_AUTHOR_NAME_KEY);
|
|
||||||
init(Constants.GIT_AUTHOR_EMAIL_KEY);
|
|
||||||
init(Constants.GIT_COMMITTER_NAME_KEY);
|
|
||||||
init(Constants.GIT_COMMITTER_EMAIL_KEY);
|
|
||||||
userGitConfig = new FileBasedConfig(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(final String n) {
|
|
||||||
values.put(n, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getenv(String variable) {
|
|
||||||
return values.get(variable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProperty(String key) {
|
|
||||||
return values.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileBasedConfig openUserConfig() {
|
|
||||||
return userGitConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHostname() {
|
|
||||||
return "fake.host.example.com";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getCurrentTime() {
|
|
||||||
return 1250379778668L; // Sat Aug 15 20:12:58 GMT-03:30 2009
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTimezone(long when) {
|
|
||||||
return TimeZone.getTimeZone("GMT-03:30").getOffset(when) / (60 * 1000);
|
|
||||||
}
|
|
||||||
}
|
|
23
pom.xml
23
pom.xml
|
@ -46,7 +46,7 @@ limitations under the License.
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jgitVersion>0.6.0-23-g36af95b7</jgitVersion>
|
<jgitVersion>0.5.1.51-g96b2e76</jgitVersion>
|
||||||
<gwtormVersion>1.1.2</gwtormVersion>
|
<gwtormVersion>1.1.2</gwtormVersion>
|
||||||
<gwtjsonrpcVersion>1.1.1</gwtjsonrpcVersion>
|
<gwtjsonrpcVersion>1.1.1</gwtjsonrpcVersion>
|
||||||
<gwtexpuiVersion>1.1.4-SNAPSHOT</gwtexpuiVersion>
|
<gwtexpuiVersion>1.1.4-SNAPSHOT</gwtexpuiVersion>
|
||||||
|
@ -673,17 +673,30 @@ limitations under the License.
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse</groupId>
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
<artifactId>jgit</artifactId>
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
<version>${jgitVersion}</version>
|
<version>${jgitVersion}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse</groupId>
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
<artifactId>jgit</artifactId>
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
<version>${jgitVersion}</version>
|
<version>${jgitVersion}</version>
|
||||||
<classifier>sources</classifier>
|
<classifier>sources</classifier>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
|
<artifactId>org.eclipse.jgit.junit</artifactId>
|
||||||
|
<version>${jgitVersion}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.eclipse.jgit</groupId>
|
||||||
|
<artifactId>org.eclipse.jgit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue