use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class RCSRepository method annotate.
@Override
Annotation annotate(File file, String revision) throws IOException {
List<String> argv = new ArrayList<>();
ensureCommand(CMD_BLAME_PROPERTY_KEY, CMD_BLAME_FALLBACK);
argv.add(RepoCommand);
if (revision != null) {
argv.add("-r");
argv.add(revision);
}
argv.add(file.getName());
Executor executor = new Executor(argv, file.getParentFile(), RuntimeEnvironment.getInstance().getInteractiveCommandTimeout());
RCSAnnotationParser annotator = new RCSAnnotationParser(file);
executor.exec(true, annotator);
return annotator.getAnnotation();
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class SubversionRepository method annotate.
@Override
public Annotation annotate(File file, String revision) throws IOException {
ArrayList<String> argv = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
argv.add(RepoCommand);
argv.add("annotate");
argv.addAll(getAuthCommandLineParams());
argv.add(NON_INTERACT_OPTION);
argv.add(XML_OPTION);
if (revision != null) {
argv.add("-r");
argv.add(revision);
}
argv.add(escapeFileName(file.getName()));
Executor executor = new Executor(argv, file.getParentFile(), RuntimeEnvironment.getInstance().getInteractiveCommandTimeout());
SubversionAnnotationParser parser = new SubversionAnnotationParser(file.getName());
int status = executor.exec(true, parser);
if (status != 0) {
LOGGER.log(Level.WARNING, "Failed to get annotations for: \"{0}\" Exit code: {1}", new Object[] { file.getAbsolutePath(), String.valueOf(status) });
throw new IOException(executor.getErrorString());
} else {
return parser.getAnnotation();
}
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class MercurialRepositoryTest method runHgCommand.
/**
* Run Mercurial command.
* @param reposRoot directory of the repository root
* @param args {@code hg} command arguments
*/
public static void runHgCommand(File reposRoot, String... args) {
List<String> cmdargs = new ArrayList<>();
MercurialRepository repo = new MercurialRepository();
cmdargs.add(repo.getRepoCommand());
cmdargs.addAll(Arrays.asList(args));
Executor exec = new Executor(cmdargs, reposRoot);
int exitCode = exec.exec();
assertEquals(0, exitCode, "hg command '" + cmdargs.toString() + "' failed." + "\nexit code: " + exitCode + "\nstdout:\n" + exec.getOutputString() + "\nstderr:\n" + exec.getErrorString());
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class CVSRepositoryTest method runCvsCommand.
/**
* Run the 'cvs' command with some arguments.
*
* @param reposRoot directory of the repository root
* @param args arguments to use for the command
*/
public static void runCvsCommand(File reposRoot, String... args) {
List<String> cmdargs = new ArrayList<>();
CVSRepository repo = new CVSRepository();
cmdargs.add(repo.getRepoCommand());
Collections.addAll(cmdargs, args);
Executor exec = new Executor(cmdargs, reposRoot);
int exitCode = exec.exec();
assertEquals(0, exitCode, "cvs command '" + cmdargs.toString() + "'failed." + "\nexit code: " + exitCode + "\nstdout:\n" + exec.getOutputString() + "\nstderr:\n" + exec.getErrorString());
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class ClearCaseRepository method runLsvob.
private static String[] runLsvob() {
if (testRepo.isWorking()) {
Executor exec = new Executor(new String[] { testRepo.RepoCommand, "lsvob", "-s" });
int rc;
if ((rc = exec.exec(true)) == 0) {
String output = exec.getOutputString();
if (output == null) {
LOGGER.log(Level.SEVERE, "\"cleartool lsvob -s\" output was null");
return new String[0];
}
String sep = System.getProperty("line.separator");
String[] vobs = output.split(Pattern.quote(sep));
LOGGER.log(Level.CONFIG, "Found VOBs: {0}", Arrays.asList(vobs));
return vobs;
}
LOGGER.log(Level.SEVERE, "\"cleartool lsvob -s\" returned non-zero status: {0}", rc);
}
return new String[0];
}
Aggregations