Skip to content

Commit 8c3d0fd

Browse files
committed
fix: 🐛 found issues should be closed
1 parent f4caa7c commit 8c3d0fd

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "auto-close-fixed-issues",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"main": "dist/index.js",
55
"files": [
66
"dist",

src/action.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,33 @@ export namespace Action {
4444
)
4545
}
4646

47-
const body = pr.body
4847
const issues: string[] = []
49-
50-
if (body) {
51-
const re = /(?:(?:resolv|clos|fix)e[ds]?|fix) +#(\d+)/gi // https://regex101.com/r/5Zet3S/1
52-
let match = re.exec(body)
48+
const collect = (body: string) => {
49+
// @see: https://regex101.com/r/5Zet3S/1
50+
const regex = /(?:(?:resolv|clos|fix)e[ds]?|fix) +#(\d+)/gi
51+
let match = regex.exec(body)
5352
while (match) {
54-
issues.push(match[1])
55-
core.info(`Found fixed issue: #${match[1]}.`)
56-
match = re.exec(body)
53+
if (!issues.includes(match[1])) {
54+
issues.push(match[1])
55+
core.info(`Found fixed issue: #${match[1]}.`)
56+
}
57+
match = regex.exec(body)
5758
}
5859
}
5960

61+
if (pr.body) {
62+
collect(pr.body)
63+
}
64+
65+
const { data: commits } = await octokit.pulls.listCommits({
66+
...context.repo,
67+
pull_number: pr.number,
68+
})
69+
70+
commits.forEach(({ commit }) => {
71+
collect(commit.message)
72+
})
73+
6074
if (issues.length === 0) {
6175
core.info(`This pull request fixes no issue. Stepping out...`)
6276
return

0 commit comments

Comments
 (0)