@Test(expected = IOException.class) public void testRunCommand_invalidRevision() throws IOException { List<String> strings = ProcessRunner.runCommand(new File("./nonexistingfolder"), "git", "diff"); assertTrue(true); }
public static List<String> runCommand(File workingDirectory, String... command) throws IOException { ProcessBuilder pb = new ProcessBuilder(command); if (workingDirectory != null) { pb.directory(workingDirectory); } pb.redirectErrorStream(true); Process p = start(pb); List<String> outputLines = getOutputLines(p); waitFor(p, command, outputLines); return outputLines; }
ProcessRunner { public static List<String> runCommand(File workingDirectory, String... command) throws IOException { ProcessBuilder pb = new ProcessBuilder(command); if (workingDirectory != null) { pb.directory(workingDirectory); } pb.redirectErrorStream(true); Process p = start(pb); List<String> outputLines = getOutputLines(p); waitFor(p, command, outputLines); return outputLines; } }
ProcessRunner { public static List<String> runCommand(File workingDirectory, String... command) throws IOException { ProcessBuilder pb = new ProcessBuilder(command); if (workingDirectory != null) { pb.directory(workingDirectory); } pb.redirectErrorStream(true); Process p = start(pb); List<String> outputLines = getOutputLines(p); waitFor(p, command, outputLines); return outputLines; } private  ProcessRunner(); }
ProcessRunner { public static List<String> runCommand(File workingDirectory, String... command) throws IOException { ProcessBuilder pb = new ProcessBuilder(command); if (workingDirectory != null) { pb.directory(workingDirectory); } pb.redirectErrorStream(true); Process p = start(pb); List<String> outputLines = getOutputLines(p); waitFor(p, command, outputLines); return outputLines; } private  ProcessRunner(); static List<String> runCommand(File workingDirectory, String... command); }
ProcessRunner { public static List<String> runCommand(File workingDirectory, String... command) throws IOException { ProcessBuilder pb = new ProcessBuilder(command); if (workingDirectory != null) { pb.directory(workingDirectory); } pb.redirectErrorStream(true); Process p = start(pb); List<String> outputLines = getOutputLines(p); waitFor(p, command, outputLines); return outputLines; } private  ProcessRunner(); static List<String> runCommand(File workingDirectory, String... command);  }