Unset userHome in FS.
This prevents arbitrary user settings state from leaking into our tests. Change-Id: If5f4230bfaede0bf9f688b2cf1a1a48de5740b55
This commit is contained in:
@@ -42,6 +42,7 @@ import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.transport.SshSessionFactory;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@@ -103,12 +104,18 @@ public class GitUtil {
|
||||
Project.NameKey project, String uri) throws Exception {
|
||||
DfsRepositoryDescription desc =
|
||||
new DfsRepositoryDescription("clone of " + project.get());
|
||||
|
||||
FS fs = FS.detect();
|
||||
|
||||
// Avoid leaking user state into our tests.
|
||||
fs.setUserHome(null);
|
||||
|
||||
InMemoryRepository dest = new InMemoryRepository.Builder()
|
||||
.setRepositoryDescription(desc)
|
||||
// SshTransport depends on a real FS to read ~/.ssh/config, but
|
||||
// InMemoryRepository by default uses a null FS.
|
||||
// TODO(dborowitz): Remove when we no longer depend on SSH.
|
||||
.setFS(FS.detect())
|
||||
.setFS(fs)
|
||||
.build();
|
||||
Config cfg = dest.getConfig();
|
||||
cfg.setString("remote", "origin", "url", uri);
|
||||
|
||||
Reference in New Issue
Block a user