public boolean shouldPublish()

in src/main/java/com/cisco/gerrit/plugins/slack/message/PatchSetCreatedMessageGenerator.java [79:123]


  public boolean shouldPublish() {
    if (!config.isEnabled() || !config.shouldPublishOnPatchSetCreated()) {
      return false;
    }

    // Ignore rebases or no code changes
    try {
      if (config.getIgnoreUnchangedPatchSet() && unchangedChangeKind(event.patchSet.get().kind)) {
        return false;
      }
    } catch (Exception e) {
      LOGGER.warn("Error checking patch set kind", e);
    }

    try {
      ChangeAttribute change;
      change = event.change.get();
      if (config.getIgnorePrivatePatchSet() && Boolean.TRUE.equals(change.isPrivate)) {
        return false;
      }
      if (config.getIgnoreWorkInProgressPatchSet() && Boolean.TRUE.equals(change.wip)) {
        return false;
      }
    } catch (Exception e) {
      LOGGER.warn("Error checking private and work-in-progress status", e);
    }

    boolean result;
    result = true;

    try {
      Pattern pattern;
      pattern = Pattern.compile(config.getIgnore(), Pattern.DOTALL);

      Matcher matcher;
      matcher = pattern.matcher(event.change.get().commitMessage);

      // If the ignore pattern matches, publishing should not happen
      result = !matcher.matches();
    } catch (Exception e) {
      LOGGER.warn("The specified ignore pattern was invalid", e);
    }

    return result;
  }