Skip to content

Commit 8afed65

Browse files
authored
Merge pull request #19 from diogotcorreia/green-status-fix
Fix green status check always failing when it has statuses
2 parents 7620005 + edda14d commit 8afed65

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ async function mergeIfLGTMAndHasAccess() {
130130

131131
// Don't merge red PRs
132132
const statusInfo = await octokit.repos.listCommitStatusesForRef({ ...thisRepo, ref: prInfo.data.head.sha })
133-
const failedStatus = statusInfo.data.find(s => s.state !== "success")
133+
const failedStatus = statusInfo.data
134+
// Check only the most recent for a set of duplicated statuses
135+
.filter(
136+
(thing, index, self) =>
137+
index === self.findIndex((t) => t.target_url === thing.target_url)
138+
)
139+
.find(s => s.state !== "success")
134140

135141
if (failedStatus) {
136142
await octokit.issues.createComment({ ...thisRepo, issue_number: issue.number, body: `Sorry @${sender}, this PR could not be merged because it wasn't green. Blocked by [${failedStatus.context}](${failedStatus.target_url}): '${failedStatus.description}'.` });

0 commit comments

Comments
 (0)