Skip to content
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

1129: [REDO] The mlbridge bot occasionally posts the same comments twice on Github #1213

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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());
}
}