org.eclipse.jgit.util.FS.runHookIfPresent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中org.eclipse.jgit.util.FS.runHookIfPresent()方法的一些代码示例,展示了FS.runHookIfPresent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FS.runHookIfPresent()方法的具体详情如下:
包路径:org.eclipse.jgit.util.FS
类名称:FS
方法名:runHookIfPresent

FS.runHookIfPresent介绍

[英]Checks whether the given hook is defined for the given repository, then runs it with the given arguments.

The hook's standard output and error streams will be redirected to System.out and System.err respectively. The hook will have no stdin.
[中]检查是否为给定的存储库定义了给定的钩子,然后使用给定的参数运行它。
钩子的标准输出和错误流将分别重定向到System.outSystem.err。钩子将没有标准。

代码示例

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Checks whether the given hook is defined for the given repository, then
 * runs it with the given arguments.
 * <p>
 * The hook's standard output and error streams will be redirected to
 * <code>System.out</code> and <code>System.err</code> respectively. The
 * hook will have no stdin.
 * </p>
 *
 * @param repository
 *            The repository for which a hook should be run.
 * @param hookName
 *            The name of the hook to be executed.
 * @param args
 *            Arguments to pass to this hook. Cannot be <code>null</code>,
 *            but can be an empty array.
 * @return The ProcessResult describing this hook's execution.
 * @throws org.eclipse.jgit.api.errors.JGitInternalException
 *             if we fail to run the hook somehow. Causes may include an
 *             interrupted process or I/O errors.
 * @since 4.0
 */
public ProcessResult runHookIfPresent(Repository repository,
    final String hookName,
    String[] args) throws JGitInternalException {
  return runHookIfPresent(repository, hookName, args, System.out, System.err,
      null);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Runs the hook, without performing any validity checks.
 *
 * @throws org.eclipse.jgit.api.errors.AbortedByHookException
 *             If the underlying hook script exited with non-zero.
 */
protected void doRun() throws AbortedByHookException {
  final ByteArrayOutputStream errorByteArray = new ByteArrayOutputStream();
  PrintStream hookErrRedirect = null;
  try {
    hookErrRedirect = new PrintStream(errorByteArray, false,
        UTF_8.name());
  } catch (UnsupportedEncodingException e) {
    // UTF-8 is guaranteed to be available
  }
  ProcessResult result = FS.DETECTED.runHookIfPresent(getRepository(),
      getHookName(), getParameters(), getOutputStream(),
      hookErrRedirect, getStdinArgs());
  if (result.isExecutedWithError()) {
    throw new AbortedByHookException(
        new String(errorByteArray.toByteArray(), UTF_8),
        getHookName(), result.getExitCode());
  }
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

/**
 * Checks whether the given hook is defined for the given repository, then
 * runs it with the given arguments.
 * <p>
 * The hook's standard output and error streams will be redirected to
 * <code>System.out</code> and <code>System.err</code> respectively. The
 * hook will have no stdin.
 * </p>
 *
 * @param repository
 *            The repository for which a hook should be run.
 * @param hookName
 *            The name of the hook to be executed.
 * @param args
 *            Arguments to pass to this hook. Cannot be <code>null</code>,
 *            but can be an empty array.
 * @return The ProcessResult describing this hook's execution.
 * @throws JGitInternalException
 *             if we fail to run the hook somehow. Causes may include an
 *             interrupted process or I/O errors.
 * @since 4.0
 */
public ProcessResult runHookIfPresent(Repository repository,
    final String hookName,
    String[] args) throws JGitInternalException {
  return runHookIfPresent(repository, hookName, args, System.out, System.err,
      null);
}

代码示例来源:origin: berlam/github-bucket

/**
 * Checks whether the given hook is defined for the given repository, then
 * runs it with the given arguments.
 * <p>
 * The hook's standard output and error streams will be redirected to
 * <code>System.out</code> and <code>System.err</code> respectively. The
 * hook will have no stdin.
 * </p>
 *
 * @param repository
 *            The repository for which a hook should be run.
 * @param hookName
 *            The name of the hook to be executed.
 * @param args
 *            Arguments to pass to this hook. Cannot be <code>null</code>,
 *            but can be an empty array.
 * @return The ProcessResult describing this hook's execution.
 * @throws org.eclipse.jgit.api.errors.JGitInternalException
 *             if we fail to run the hook somehow. Causes may include an
 *             interrupted process or I/O errors.
 * @since 4.0
 */
public ProcessResult runHookIfPresent(Repository repository,
    final String hookName,
    String[] args) throws JGitInternalException {
  return runHookIfPresent(repository, hookName, args, System.out, System.err,
      null);
}

代码示例来源:origin: berlam/github-bucket

/**
 * Runs the hook, without performing any validity checks.
 *
 * @throws org.eclipse.jgit.api.errors.AbortedByHookException
 *             If the underlying hook script exited with non-zero.
 */
protected void doRun() throws AbortedByHookException {
  final ByteArrayOutputStream errorByteArray = new ByteArrayOutputStream();
  PrintStream hookErrRedirect = null;
  try {
    hookErrRedirect = new PrintStream(errorByteArray, false,
        UTF_8.name());
  } catch (UnsupportedEncodingException e) {
    // UTF-8 is guaranteed to be available
  }
  ProcessResult result = FS.DETECTED.runHookIfPresent(getRepository(),
      getHookName(), getParameters(), getOutputStream(),
      hookErrRedirect, getStdinArgs());
  if (result.isExecutedWithError()) {
    throw new AbortedByHookException(
        new String(errorByteArray.toByteArray(), UTF_8),
        getHookName(), result.getExitCode());
  }
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

/**
 * Runs the hook, without performing any validity checks.
 *
 * @throws AbortedByHookException
 *             If the underlying hook script exited with non-zero.
 */
protected void doRun() throws AbortedByHookException {
  final ByteArrayOutputStream errorByteArray = new ByteArrayOutputStream();
  final PrintStream hookErrRedirect = new PrintStream(errorByteArray);
  ProcessResult result = FS.DETECTED.runHookIfPresent(getRepository(),
      getHookName(), getParameters(), getOutputStream(),
      hookErrRedirect, getStdinArgs());
  if (result.isExecutedWithError()) {
    throw new AbortedByHookException(errorByteArray.toString(),
        getHookName(), result.getExitCode());
  }
}

代码示例来源:origin: kiegroup/appformer

private void postCommitHook(final JGitFileSystem fileSystem) {
  ProcessResult result = detectedFS.runHookIfPresent(fileSystem.getGit().getRepository(), "post-commit", new String[0]);
  if(result.getStatus().equals(ProcessResult.Status.OK)) {
    fileSystem.notifyPostCommit(result.getExitCode());
  }
}

相关文章