Skip to content

Commit af788c8

Browse files
fix: fixed logic in push event API request to only get commits from before to after event
1 parent 9e28575 commit af788c8

File tree

3 files changed

+309
-93
lines changed

3 files changed

+309
-93
lines changed

src/action.mjs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,22 @@ const getCommitDepth = () => {
2222
return Number.isNaN(commitDepth) ? null : Math.max(commitDepth, 0)
2323
}
2424

25-
const getPushEventCommits = () => {
26-
const mappedCommits = eventContext.payload.commits.map((commit) => ({
27-
message: commit.message,
28-
hash: commit.id,
29-
}))
25+
const getPushEventCommits = async () => {
26+
const octokit = getOctokit(getInput('token'))
27+
const { owner, repo } = eventContext.issue
28+
const { before, after } = eventContext.payload
29+
const { data: comparison } = await octokit.rest.repos.compareCommits({
30+
owner,
31+
repo,
32+
head: after,
33+
base: before,
34+
per_page: 100,
35+
})
3036

31-
return mappedCommits
37+
return comparison.commits.map((commit) => ({
38+
message: commit.commit.message,
39+
hash: commit.sha,
40+
}))
3241
}
3342

3443
const getPullRequestEventCommits = async () => {

0 commit comments

Comments
 (0)