-
Notifications
You must be signed in to change notification settings - Fork 13
[SET-659] add check on Issue/Ticket state if PR is up #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
baranowb
wants to merge
1
commit into
jboss-set:master
Choose a base branch
from
baranowb:SET-659
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/org/jboss/set/pull/processor/impl/evaluator/IssueClosedLabelEvaluator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
src/main/java/org/jboss/set/pull/processor/impl/evaluator/IssueWrongStateLabelEvaluator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be simplified to |
||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.