Exemplo n.º 1
0
 public boolean setStatus(DefaultIssue issue, String status, IssueChangeContext context) {
   if (!Objects.equal(status, issue.status())) {
     issue.setFieldChange(context, STATUS, issue.status(), status);
     issue.setStatus(status);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
Exemplo n.º 2
0
 public boolean setResolution(
     DefaultIssue issue, @Nullable String resolution, IssueChangeContext context) {
   if (!Objects.equal(resolution, issue.resolution())) {
     issue.setFieldChange(context, RESOLUTION, issue.resolution(), resolution);
     issue.setResolution(resolution);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
Exemplo n.º 3
0
 public boolean setManualSeverity(
     DefaultIssue issue, String severity, IssueChangeContext context) {
   if (!issue.manualSeverity() || !Objects.equal(severity, issue.severity())) {
     issue.setFieldChange(context, SEVERITY, issue.severity(), severity);
     issue.setSeverity(severity);
     issue.setManualSeverity(true);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
Exemplo n.º 4
0
 public boolean assign(DefaultIssue issue, @Nullable User user, IssueChangeContext context) {
   String sanitizedAssignee = null;
   if (user != null) {
     sanitizedAssignee = StringUtils.defaultIfBlank(user.login(), null);
   }
   if (!Objects.equal(sanitizedAssignee, issue.assignee())) {
     String newAssignee = user != null ? user.name() : null;
     issue.setFieldChange(context, ASSIGNEE, UNUSED, newAssignee);
     issue.setAssignee(sanitizedAssignee);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
Exemplo n.º 5
0
 public boolean plan(
     DefaultIssue issue, @Nullable ActionPlan actionPlan, IssueChangeContext context) {
   String sanitizedActionPlanKey = null;
   if (actionPlan != null) {
     sanitizedActionPlanKey = StringUtils.defaultIfBlank(actionPlan.key(), null);
   }
   if (!Objects.equal(sanitizedActionPlanKey, issue.actionPlanKey())) {
     String newActionPlanName = actionPlan != null ? actionPlan.name() : null;
     issue.setFieldChange(context, ACTION_PLAN, UNUSED, newActionPlanName);
     issue.setActionPlanKey(sanitizedActionPlanKey);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
Exemplo n.º 6
0
  public boolean setTags(DefaultIssue issue, Collection<String> tags, IssueChangeContext context) {
    Set<String> newTags =
        Sets.newHashSet(
            Collections2.transform(
                Collections2.filter(
                    tags,
                    new Predicate<String>() {
                      @Override
                      public boolean apply(@Nullable String tag) {
                        return tag != null && !tag.isEmpty();
                      }
                    }),
                new Function<String, String>() {
                  @Override
                  public String apply(String tag) {
                    String lowerCaseTag = tag.toLowerCase();
                    RuleTagFormat.validate(lowerCaseTag);
                    return lowerCaseTag;
                  }
                }));

    Set<String> oldTags = Sets.newHashSet(issue.tags());

    if (!oldTags.equals(newTags)) {
      issue.setFieldChange(
          context,
          TAGS,
          oldTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(oldTags),
          newTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(newTags));
      issue.setTags(newTags);
      issue.setUpdateDate(context.date());
      issue.setChanged(true);
      issue.setSendNotifications(true);
      return true;
    }
    return false;
  }