Esempio n. 1
0
  private static String _getGitResult(
      Project project, final File workingDir, final String... args) {

    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    try {
      project.exec(
          new Action<ExecSpec>() {

            @Override
            public void execute(ExecSpec execSpec) {
              execSpec.setArgs(Arrays.asList(args));
              execSpec.setExecutable("git");
              execSpec.setStandardOutput(byteArrayOutputStream);
              execSpec.setWorkingDir(workingDir);
            }
          });
    } catch (ExecException ee) {
      if (_logger.isInfoEnabled()) {
        _logger.info(ee.getMessage(), ee);
      }
    }

    return byteArrayOutputStream.toString();
  }