Skip to content

Commit

Permalink
fix: fixed logic in push event API request to only get commits from b…
Browse files Browse the repository at this point in the history
…efore to after event
  • Loading branch information
Brian-Triplett committed Aug 22, 2024
1 parent 9e28575 commit af788c8
Show file tree
Hide file tree
Showing 3 changed files with 309 additions and 93 deletions.
21 changes: 15 additions & 6 deletions src/action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@ const getCommitDepth = () => {
return Number.isNaN(commitDepth) ? null : Math.max(commitDepth, 0)
}

const getPushEventCommits = () => {
const mappedCommits = eventContext.payload.commits.map((commit) => ({
message: commit.message,
hash: commit.id,
}))
const getPushEventCommits = async () => {
const octokit = getOctokit(getInput('token'))
const { owner, repo } = eventContext.issue
const { before, after } = eventContext.payload
const { data: comparison } = await octokit.rest.repos.compareCommits({
owner,
repo,
head: after,
base: before,
per_page: 100,
})

return mappedCommits
return comparison.commits.map((commit) => ({
message: commit.commit.message,
hash: commit.sha,
}))
}

const getPullRequestEventCommits = async () => {
Expand Down
Loading

0 comments on commit af788c8

Please sign in to comment.