Search in sources :

Example 46 with Executor

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();
}
Also used : Executor(org.opengrok.indexer.util.Executor) ArrayList(java.util.ArrayList)

Example 47 with Executor

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();
    }
}
Also used : Executor(org.opengrok.indexer.util.Executor) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 48 with Executor

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());
}
Also used : Executor(org.opengrok.indexer.util.Executor) ArrayList(java.util.ArrayList)

Example 49 with Executor

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());
}
Also used : Executor(org.opengrok.indexer.util.Executor) ArrayList(java.util.ArrayList)

Example 50 with Executor

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];
}
Also used : Executor(org.opengrok.indexer.util.Executor)

Aggregations

Executor (org.opengrok.indexer.util.Executor)63 ArrayList (java.util.ArrayList)48 File (java.io.File)31 IOException (java.io.IOException)30 BufferedReader (java.io.BufferedReader)4 RuntimeEnvironment (org.opengrok.indexer.configuration.RuntimeEnvironment)4 Properties (java.util.Properties)3 Matcher (java.util.regex.Matcher)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 Path (java.nio.file.Path)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Scanner (java.util.Scanner)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1