Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public static enum LabelContent {
Missing_issue("Missing issue"),
Missing_upstream_PR("Missing upstream PR"),
Corrupted_upgrade_meta("Corrupted upgrade"),
Corrupted_issue_closed("Corrupted issue closed"),
Corrupted_issue_wrong_state("Corrupted issue in wrong state"),
Upstream_PR_Repository_Mismatch("Upstream PR repository mismatched"),
Upstream_PR_Branch_Mismatch("Upstream PR branch mismatched");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2024, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.set.pull.processor.impl.evaluator;

import org.jboss.set.aphrodite.domain.IssueStatus;
import org.jboss.set.pull.processor.EvaluatorContext;
import org.jboss.set.pull.processor.ProcessorPhase;
import org.jboss.set.pull.processor.data.DefinedLabelItem;
import org.jboss.set.pull.processor.data.DefinedLabelItem.LabelContent;
import org.jboss.set.pull.processor.data.EvaluatorData;
import org.jboss.set.pull.processor.data.EvaluatorData.Attribute;
import org.jboss.set.pull.processor.data.IssueData;
import org.jboss.set.pull.processor.data.LabelData;
import org.jboss.set.pull.processor.data.LabelItem;

/**
* Check if PR has been orphaned - ie, ticket has been closed, but PR is still open.
*
* @author baranowb
*
*/
public class IssueClosedLabelEvaluator extends AbstractLabelEvaluator {

@Override
public void eval(final EvaluatorContext context, final EvaluatorData data) {
processPresenceLabel(EvaluatorData.Attributes.ISSUE_CURRENT, EvaluatorData.Attributes.LABELS_CURRENT,
LabelContent.Corrupted_issue_closed, data, context);

}

protected void processPresenceLabel(final Attribute<IssueData> issueKey, final Attribute<LabelData> labelsKey,
final LabelContent expectoPatronum, final EvaluatorData data, final EvaluatorContext context) {
LabelData labelData = super.getLabelData(labelsKey, data);
final IssueData issueToProcess = data.getAttributeValue(issueKey);
final IssueStatus status = issueToProcess.getIssue().getStatus();
if (issueToProcess.isDefined() && ( status == IssueStatus.CLOSED || status == IssueStatus.VERIFIED || status == IssueStatus.MODIFIED)) {
LabelItem<?> li = new DefinedLabelItem(expectoPatronum, LabelItem.LabelAction.SET, LabelItem.LabelSeverity.BAD);
labelData.addLabelItem(li);
} else {
LabelItem<?> li = new DefinedLabelItem(expectoPatronum, LabelItem.LabelAction.REMOVE, LabelItem.LabelSeverity.OK);
labelData.addLabelItem(li);
}
}

@Override
public boolean support(ProcessorPhase processorPhase) {
if (processorPhase == ProcessorPhase.OPEN) {
return true;
}
return false;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2024, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.set.pull.processor.impl.evaluator;

import org.jboss.set.aphrodite.domain.IssueStatus;
import org.jboss.set.pull.processor.EvaluatorContext;
import org.jboss.set.pull.processor.ProcessorPhase;
import org.jboss.set.pull.processor.data.DefinedLabelItem;
import org.jboss.set.pull.processor.data.DefinedLabelItem.LabelContent;
import org.jboss.set.pull.processor.data.EvaluatorData;
import org.jboss.set.pull.processor.data.EvaluatorData.Attribute;
import org.jboss.set.pull.processor.data.IssueData;
import org.jboss.set.pull.processor.data.LabelData;
import org.jboss.set.pull.processor.data.LabelItem;

/**
* Force ticket update if not set. Closed states are handled differently.
*
* @author baranowb
*
*/
public class IssueWrongStateLabelEvaluator extends AbstractLabelEvaluator {

@Override
public void eval(final EvaluatorContext context, final EvaluatorData data) {
processPresenceLabel(EvaluatorData.Attributes.ISSUE_CURRENT, EvaluatorData.Attributes.LABELS_CURRENT,
LabelContent.Corrupted_issue_wrong_state, data, context);

}

protected void processPresenceLabel(final Attribute<IssueData> issueKey, final Attribute<LabelData> labelsKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first three parameters seems unnecessary for this method, you can just use the actual value inside this method. The last parameter context also useless in this method.

final LabelContent expectoPatronum, final EvaluatorData data, final EvaluatorContext context) {
LabelData labelData = super.getLabelData(labelsKey, data);
final IssueData issueToProcess = data.getAttributeValue(issueKey);
final IssueStatus status = issueToProcess.getIssue().getStatus();
if (issueToProcess.isDefined() && ( status == IssueStatus.CREATED || status == IssueStatus.NEW || status == IssueStatus.ASSIGNED || status == IssueStatus.ON_QA)) {
LabelItem<?> li = new DefinedLabelItem(expectoPatronum, LabelItem.LabelAction.SET, LabelItem.LabelSeverity.BAD);
labelData.addLabelItem(li);
} else {
LabelItem<?> li = new DefinedLabelItem(expectoPatronum, LabelItem.LabelAction.REMOVE, LabelItem.LabelSeverity.OK);
labelData.addLabelItem(li);
}
}

@Override
public boolean support(ProcessorPhase processorPhase) {
if (processorPhase == ProcessorPhase.OPEN) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified to return processorPhase == ProcessorPhase.OPEN

return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ org.jboss.set.pull.processor.impl.evaluator.LinkedIssuesEvaluator
org.jboss.set.pull.processor.impl.evaluator.LinkedPullRequestEvaluator
org.jboss.set.pull.processor.impl.evaluator.IssueACKFlagsLabelEvaluator
org.jboss.set.pull.processor.impl.evaluator.IssuePresentLabelEvaluator
org.jboss.set.pull.processor.impl.evaluator.IssueClosedLabelEvaluator
org.jboss.set.pull.processor.impl.evaluator.IssueWrongStateLabelEvaluator
org.jboss.set.pull.processor.impl.evaluator.UpstreamPullRequestLabelEvaluator
org.jboss.set.pull.processor.impl.evaluator.DevStreamLabelEvaluator