From 42f22af62929edadff33ffbcd750fe008d5db95f Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 7 Aug 2012 18:12:16 +0400 Subject: [PATCH] GitTestRunEnv: save the detected executable in static field to reuse in this session; use more clean logging --- .../git4idea/tests/git4idea/test/GitTestRunEnv.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/git4idea/tests/git4idea/test/GitTestRunEnv.java b/plugins/git4idea/tests/git4idea/test/GitTestRunEnv.java index 482a10b9ddb9..167e124bbc55 100644 --- a/plugins/git4idea/tests/git4idea/test/GitTestRunEnv.java +++ b/plugins/git4idea/tests/git4idea/test/GitTestRunEnv.java @@ -34,7 +34,8 @@ import java.io.IOException; public class GitTestRunEnv { public static final String GIT_EXECUTABLE_ENV = "IDEA_TEST_GIT_EXECUTABLE"; - private String gitExecutable; + private static String ourGitExecutable; + private File myRootDir; private int myRetryCount; @@ -42,7 +43,7 @@ public class GitTestRunEnv { public GitTestRunEnv(@NotNull File rootDir) { - gitExecutable = getExecutable(); + ourGitExecutable = getExecutable(); myRootDir = rootDir; } @@ -56,9 +57,9 @@ public class GitTestRunEnv { } public String run(boolean silent, @NotNull String command, String... params) throws IOException { - String[] arguments = ArrayUtil.mergeArrays(new String[]{gitExecutable, command}, params); + String[] arguments = ArrayUtil.mergeArrays(new String[]{ourGitExecutable, command}, params); if (!silent) { - log("# " + StringUtil.join(arguments, " ")); + log("# git " + command + " " + StringUtil.join(params, " ")); } final ProcessBuilder builder = new ProcessBuilder().command(arguments); builder.directory(myRootDir); @@ -97,6 +98,9 @@ public class GitTestRunEnv { } private String getExecutable() { + if (ourGitExecutable != null) { + return ourGitExecutable; + } String exec = System.getenv(GIT_EXECUTABLE_ENV); if (exec != null && new File(exec).exists()) { log("Using Git from GIT_EXECUTABLE_ENV: " + exec);