Skip to content

Commit 66bbee8

Browse files
mkan0141pieh
authored andcommitted
feat(high-priority-prs): ignore master merge commits (gatsbyjs#14352)
* Update high-priority-prs action * Fix consider many commit * Update reduce false negative case
1 parent c6bbe4b commit 66bbee8

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

.github/actions/high-priority-prs/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ query GitHubOpenPullRequestsQuery {
2727
}
2828
}
2929
}
30-
commits(last: 1) {
30+
commits(last: 50) {
3131
totalCount
3232
nodes {
3333
commit {
3434
authoredDate
35+
message
3536
}
3637
}
3738
}

.github/actions/high-priority-prs/process.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ const maintainers = {
8383
},
8484
}
8585

86+
const ignoreMessages = [
87+
"Merge branch 'master'",
88+
"Merge remote-tracking branch"
89+
]
90+
8691
module.exports = data => {
8792
const prs = data.repository.pullRequests
8893

@@ -147,12 +152,29 @@ module.exports = data => {
147152
// What PRs have commits (aka activity) since the last comment by
148153
// a maintainer.
149154
prs.nodes.forEach(pr => {
155+
const authorUrl = pr.author.url
156+
const botUrl = "https://github.com/apps/gatsbot"
157+
158+
const reviewList = pr.comments.nodes.filter(x =>
159+
(x.author.url !== authorUrl && x.author.url !== botUrl)
160+
)
150161
const lastComment = _.get(
151-
_.maxBy(pr.comments.nodes, n => n.createdAt),
162+
_.maxBy(reviewList, n => n.createdAt),
152163
`createdAt`
153164
)
154-
const lastCommit = pr.commits.nodes[0].commit.authoredDate
155-
commitNewerThanComment = lastComment < lastCommit
165+
166+
let commitMessages = []
167+
pr.commits.nodes.forEach(c => {
168+
const message = c.commit.message
169+
if(ignoreMessages.every(im => message.indexOf(im) === -1) ) {
170+
commitMessages.push(c)
171+
} else {
172+
commitMessages = []
173+
}
174+
})
175+
176+
commitMessages = commitMessages.filter(c => lastComment < c.commit.authoredDate)
177+
commitNewerThanComment = (commitMessages.length !== 0)
156178

157179
if (
158180
commitNewerThanComment &&

0 commit comments

Comments
 (0)