public List onRefOperation()

in src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java [45:69]


  public List<ValidationMessage> onRefOperation(RefReceivedEvent refEvent)
      throws ValidationException {
    String projectName = refEvent.project.getName();

    HookArgs args = hookFactory.createArgs();
    args.add("--project", projectName);
    args.add("--uploader", refEvent.user.getNameEmail());
    args.add("--uploader-username", refEvent.user.getUserName().orElse(null));
    args.add("--oldrev", getObjectId(refEvent.command.getOldId()).getName());
    args.add("--newrev", getObjectId(refEvent.command.getNewId()).getName());
    args.add("--refname", refEvent.command.getRefName());

    HookResult result = hook.execute(projectName, args);
    if (result != null) {
      String output = result.toString();
      if (result.getExitValue() != 0) {
        throw new ValidationException(output);
      }
      if (!output.isEmpty()) {
        return ImmutableList.of(new ValidationMessage(output, false));
      }
    }

    return Collections.emptyList();
  }