Skip to content
Permalink
Browse files
1058: The mlbridge bot occasionally posts the same comments twice on …
…Github

Reviewed-by: kcr
  • Loading branch information
erikj79 committed Jul 16, 2021
1 parent a9de6a6 commit fd42d900459c2e1c9301ab341ad6f081cc0bf4b2
@@ -86,10 +86,7 @@ public boolean concurrentWith(WorkItem other) {
return true;
}
PullRequestCloserBotWorkItem otherItem = (PullRequestCloserBotWorkItem)other;
if (!pr.id().equals(otherItem.pr.id())) {
return true;
}
if (!repository.name().equals(otherItem.repository.name())) {
if (!pr.isSame(otherItem.pr)) {
return true;
}
return false;
@@ -49,10 +49,7 @@ public boolean concurrentWith(WorkItem other) {
return true;
}
PullRequestPrunerBotWorkItem otherItem = (PullRequestPrunerBotWorkItem) other;
if (!pr.id().equals(otherItem.pr.id())) {
return true;
}
if (!pr.repository().name().equals(otherItem.pr.repository().name())) {
if (!pr.isSame(otherItem.pr)) {
return true;
}
return false;
@@ -70,10 +70,7 @@ public boolean concurrentWith(WorkItem other) {
}
return false;
}
if (!pr.id().equals(otherArchiveItem.pr.id())) {
return true;
}
if (!bot.codeRepo().name().equals(otherArchiveItem.bot.codeRepo().name())) {
if (!pr.isSame(otherArchiveItem.pr)) {
return true;
}
return false;
@@ -55,7 +55,7 @@ public boolean concurrentWith(WorkItem other) {
return true;
}
CommentPosterWorkItem otherItem = (CommentPosterWorkItem) other;
if (!pr.equals(otherItem.pr)) {
if (!pr.isSame(otherItem.pr)) {
return true;
}
var otherItemIds = otherItem.newMessages.stream()
@@ -160,10 +160,7 @@ public boolean concurrentWith(WorkItem other) {
return true;
}
PullRequestWorkItem otherItem = (PullRequestWorkItem)other;
if (!pr.id().equals(otherItem.pr.id())) {
return true;
}
if (!pr.repository().name().equals(otherItem.pr.repository().name())) {
if (!pr.isSame(otherItem.pr)) {
return true;
}
return false;
@@ -44,10 +44,7 @@ public final boolean concurrentWith(WorkItem other) {
return true;
}
PullRequestWorkItem otherItem = (PullRequestWorkItem)other;
if (!pr.id().equals(otherItem.pr.id())) {
return true;
}
if (!pr.repository().name().equals(otherItem.pr.repository().name())) {
if (!pr.isSame(otherItem.pr)) {
return true;
}
return false;
@@ -58,10 +58,7 @@ public boolean concurrentWith(WorkItem other) {
if (!executor.checkName().equals(otherItem.executor.checkName())) {
return true;
}
if (!pr.id().equals(otherItem.pr.id())) {
return true;
}
if (!bot.repository().name().equals(otherItem.bot.repository().name())) {
if (!pr.isSame(otherItem.pr)) {
return true;
}
return false;
@@ -54,10 +54,10 @@ public boolean concurrentWith(WorkItem other) {
return true;
}
var o = (TestUpdateNeededWorkItem) other;
if (!pr.repository().url().equals(o.pr.repository().url())) {
if (!pr.isSame(o.pr)) {
return true;
}
return !pr.id().equals(o.pr.id());
return false;
}

@Override
@@ -71,10 +71,10 @@ public boolean concurrentWith(WorkItem other) {
return true;
}
var o = (TestWorkItem) other;
if (!repository.url().equals(o.repository.url())) {
if (!pr.isSame(o.pr)) {
return true;
}
return !pr.id().equals(o.pr.id());
return false;
}


@@ -163,4 +163,13 @@ public interface PullRequest extends Issue {
void setTargetRef(String targetRef);

URI filesUrl(Hash hash);

/**
* Returns true if this PullRequest represents the same pull request as the other.
*/
default boolean isSame(PullRequest other) {
return id().equals(other.id())
&& repository().name().equals(other.repository().name())
&& repository().forge().name().equals(other.repository().forge().name());
}
}

1 comment on commit fd42d90

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on fd42d90 Jul 16, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.