Skip to content

Commit

Permalink
fix: improve how we find the new merge box (#35)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DouglasBlackwood authored Jan 9, 2025
1 parent aab5c23 commit 0870ab5
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/mergify.js
Original file line number Diff line number Diff line change
@@ -222,6 +222,25 @@ function isGitHubPullRequestPage() {
}


function findNewMergeBox() {
// NOTE(charly): we look for the new merge box by looking for one of the
// following sections: Conflicts, Reviews, Checks. The new merge box hasn't
// a distinct class or id.
var conflictSection = document.querySelector("section[aria-label=Conflicts")
if (conflictSection) {
return conflictSection.parentElement
}
var reviewSection = document.querySelector("section[aria-label=Reviews")
if (reviewSection) {
return reviewSection.parentElement
}
var checksSection = document.querySelector("section[aria-label=Checks")
if (checksSection) {
return checksSection.parentElement
}
}


function tryInject() {
if (!isGitHubPullRequestPage()) {
return
@@ -244,9 +263,8 @@ function tryInject() {
detailSection.insertBefore(buildMergifySectionForClassicMergeBox(), detailSection.firstChild)
} else {
// New merge box (parent div of the conflict section, which is always present)
var conflictSection = document.querySelector("section[aria-label=Conflicts")
if (conflictSection) {
var detailSection = conflictSection.parentElement
var detailSection = findNewMergeBox()
if (detailSection) {
detailSection.insertBefore(buildMergifySectionForNewMergeBox(), detailSection.firstChild)
}
}

0 comments on commit 0870ab5

Please sign in to comment.