Skip to content

Commit 8e63f59

Browse files
committed
Affect triage/needs-rebase on Pull Requests with merge conflicts
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
1 parent 97c1f24 commit 8e63f59

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

README.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ The bot will automatically remove these labels when they are outdated:
167167

168168
The bot enforces a specific color for any label created that starts with `area/` so that all these labels are consistent.
169169

170+
=== Include `triage/needs-rebase` on unmergeable pull-requests
171+
172+
Pull requests may require a rebase when conflicts appear. The bot includes a `triage/needs-rebase` label on pull-requests that cannot be merged and removes it when the pull-request is in a mergeable state again.
173+
174+
170175
== Contributing
171176

172177
To participate to the development of this GitHub App, create a playground project in your own org and
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.quarkus.bot;
2+
3+
import io.quarkiverse.githubapp.event.Push;
4+
import io.quarkus.bot.util.Labels;
5+
import org.kohsuke.github.GHEventPayload;
6+
import org.kohsuke.github.GHIssueState;
7+
import org.kohsuke.github.GHPullRequest;
8+
import org.kohsuke.github.GHRepository;
9+
10+
import java.io.IOException;
11+
12+
/**
13+
* Actions on all opened pull-requests
14+
*/
15+
public class AffectTriageNeedsRebaseOnOpenedPullRequests {
16+
17+
void triageNeedsRebase(@Push GHEventPayload.Push pushRequestPayload) throws IOException {
18+
GHRepository repository = pushRequestPayload.getRepository();
19+
for (GHPullRequest pullRequest : repository.getPullRequests(GHIssueState.OPEN)) {
20+
Boolean mergeable = pullRequest.getMergeable();
21+
if (mergeable != null) {
22+
if (mergeable) {
23+
pullRequest.removeLabels(Labels.TRIAGE_NEEDS_REBASE);
24+
} else {
25+
pullRequest.addLabels(Labels.TRIAGE_NEEDS_REBASE);
26+
}
27+
}
28+
}
29+
}
30+
}

src/main/java/io/quarkus/bot/util/Labels.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class Labels {
1414
public static final String AREA_PREFIX = "area/";
1515
public static final String AREA_INFRA = "area/infra";
1616
public static final String TRIAGE_INVALID = "triage/invalid";
17+
public static final String TRIAGE_NEEDS_REBASE = "triage/needs-rebase";
1718
public static final String TRIAGE_NEEDS_TRIAGE = "triage/needs-triage";
1819
public static final String TRIAGE_WAITING_FOR_CI = "triage/waiting-for-ci";
1920
public static final String TRIAGE_QE = "triage/qe?";

0 commit comments

Comments
 (0)