Skip to content

Commit

Permalink
Affect triage/needs-rebase on Pull Requests with merge conflicts
Browse files Browse the repository at this point in the history
This adds the `triage/needs-rebase` label (or removes it) on opened pull-requests, making it easier to find pull-requests that require a rebase to be merged
  • Loading branch information
gastaldi committed Jun 9, 2022
1 parent 97c1f24 commit 8eca863
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/io/quarkus/bot/MarkPullRequestAsNeedsRebase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.quarkus.bot;

import io.quarkiverse.githubapp.event.Push;
import io.quarkus.bot.util.Labels;
import org.kohsuke.github.GHEventPayload;
import org.kohsuke.github.GHIssueState;
import org.kohsuke.github.GHPullRequest;
import org.kohsuke.github.GHRepository;

import java.io.IOException;

public class MarkPullRequestAsNeedsRebase {

void maintainNeedsRebaseLabel(@Push GHEventPayload.Push pushRequestPayload) throws IOException {
GHRepository repository = pushRequestPayload.getRepository();
for (GHPullRequest pullRequest : repository.getPullRequests(GHIssueState.OPEN)) {
Boolean mergeable = pullRequest.getMergeable();
if (mergeable != null) {
if (mergeable) {
pullRequest.removeLabels(Labels.TRIAGE_NEEDS_REBASE);
} else {
pullRequest.addLabels(Labels.TRIAGE_NEEDS_REBASE);
}
}
}
}
}
1 change: 1 addition & 0 deletions src/main/java/io/quarkus/bot/util/Labels.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class Labels {
public static final String AREA_PREFIX = "area/";
public static final String AREA_INFRA = "area/infra";
public static final String TRIAGE_INVALID = "triage/invalid";
public static final String TRIAGE_NEEDS_REBASE = "triage/needs-rebase";
public static final String TRIAGE_NEEDS_TRIAGE = "triage/needs-triage";
public static final String TRIAGE_WAITING_FOR_CI = "triage/waiting-for-ci";
public static final String TRIAGE_QE = "triage/qe?";
Expand Down

0 comments on commit 8eca863

Please sign in to comment.