protected void runGitCommand()

in git-agent/src/main/java/jetbrains/buildServer/buildTriggers/vcs/git/agent/CheckoutDirectoryCleaner.java [111:155]


  protected void runGitCommand(@NotNull File repo, @NotNull String pathToGit, @NotNull String cmdName, int timeout, @NotNull String... params) {
    final String cmd = " '" + cmdName + "' in repo " + repo.getAbsolutePath();
    try {
      final GeneralCommandLine cl = new GeneralCommandLine();
      cl.setWorkingDirectory(repo);
      cl.setExePath(pathToGit);
      cl.addParameters(params);

      final long start = System.currentTimeMillis();
      ExecResult result = SimpleCommandLineProcessRunner.runCommand(cl, null, new SimpleCommandLineProcessRunner.ProcessRunCallback() {
        @Override
        public void onProcessStarted(@NotNull Process ps) {
          LOG.debug("Start" + cmd);
        }
        @Override
        public void onProcessFinished(@NotNull Process ps) {
          final long finish = System.currentTimeMillis();
          LOG.debug("Finish" + cmd + ", duration: " + (finish - start) + "ms");
        }
        @Override
        public Integer getOutputIdleSecondsTimeout() {
          return timeout;
        }
        @Override
        public Integer getMaxAcceptedOutputSize() {
          return COMMAND_OUTPUT_THRESHOLD;
        }
        @Override
        public boolean terminateEntireProcessTree() {
          return false;
        }
      });

      final VcsException commandError = CommandLineUtil.getCommandLineError(cmd, result);
      if (commandError != null) {
        LOG.warnAndDebugDetails("Error while running" + cmd, commandError);
      }
      if (result.getStderr().length() > 0) {
        LOG.debug("Output produced by" + cmd);
        LOG.debug(result.getStderr());
      }
    } catch (Exception e) {
      LOG.debug("Error while running" + cmd, e);
    }
  }