From 76a76123aff32f4365fafbdf450ad9e047344fd9 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Tue, 31 Dec 2013 14:37:56 +0100 Subject: [PATCH] Remove code duplication. --- .../com/intellij/openapi/vcs/Executor.java | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/Executor.java b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/Executor.java index 5f40300f09c6..0c7de0a55a36 100644 --- a/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/Executor.java +++ b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/Executor.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.vcs; +import com.intellij.execution.configurations.PathEnvironmentVariableUtil; import com.intellij.execution.process.CapturingProcessHandler; import com.intellij.execution.process.ProcessOutput; import com.intellij.openapi.util.SystemInfo; @@ -196,30 +197,15 @@ public class Executor { if (exec != null) { return exec; } - exec = findInPath(programName, unixExec, winExec); - if (exec != null) { - return exec; + File fileExec = PathEnvironmentVariableUtil.findInPath(SystemInfo.isWindows ? winExec : unixExec); + if (fileExec != null) { + return fileExec.getAbsolutePath(); } throw new IllegalStateException(programName + " executable not found. " + "Please define a valid environment variable " + pathEnvs.iterator().next() + " pointing to the " + programName + " executable."); } - protected static String findInPath(String programName, String unixExec, String winExec) { - String path = System.getenv(SystemInfo.isWindows ? "Path" : "PATH"); - if (path != null) { - String name = SystemInfo.isWindows ? winExec : unixExec; - for (String dir : path.split(File.pathSeparator)) { - File file = new File(dir, name); - if (file.canExecute()) { - log("Using " + programName + " from PATH: " + file.getPath()); - return file.getPath(); - } - } - } - return null; - } - protected static String findInPathEnvs(String programName, Collection pathEnvs) { for (String pathEnv : pathEnvs) { String exec = System.getenv(pathEnv);