Skip to content

Commit 0870ab5

Browse files
fix: improve how we find the new merge box (#35)
The conflict section isn't always there (when the pull request is up to date). As the merge box hasn't a distinct class or id, we have to look for others sections like Checks or Reviews.
1 parent aab5c23 commit 0870ab5

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/mergify.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,25 @@ function isGitHubPullRequestPage() {
222222
}
223223

224224

225+
function findNewMergeBox() {
226+
// NOTE(charly): we look for the new merge box by looking for one of the
227+
// following sections: Conflicts, Reviews, Checks. The new merge box hasn't
228+
// a distinct class or id.
229+
var conflictSection = document.querySelector("section[aria-label=Conflicts")
230+
if (conflictSection) {
231+
return conflictSection.parentElement
232+
}
233+
var reviewSection = document.querySelector("section[aria-label=Reviews")
234+
if (reviewSection) {
235+
return reviewSection.parentElement
236+
}
237+
var checksSection = document.querySelector("section[aria-label=Checks")
238+
if (checksSection) {
239+
return checksSection.parentElement
240+
}
241+
}
242+
243+
225244
function tryInject() {
226245
if (!isGitHubPullRequestPage()) {
227246
return
@@ -244,9 +263,8 @@ function tryInject() {
244263
detailSection.insertBefore(buildMergifySectionForClassicMergeBox(), detailSection.firstChild)
245264
} else {
246265
// New merge box (parent div of the conflict section, which is always present)
247-
var conflictSection = document.querySelector("section[aria-label=Conflicts")
248-
if (conflictSection) {
249-
var detailSection = conflictSection.parentElement
266+
var detailSection = findNewMergeBox()
267+
if (detailSection) {
250268
detailSection.insertBefore(buildMergifySectionForNewMergeBox(), detailSection.firstChild)
251269
}
252270
}

0 commit comments

Comments
 (0)