Skip to content

Commit

Permalink
fix: fallback to author date and current date
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Nov 19, 2024
1 parent 359e915 commit b2dd46b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,11 @@ async function getCommitDateFromWorkflow(sha: string, toolkit: Toolkit): Promise
repo: GitHub.context.repo.repo
});

return new Date(commit.data.committer.date);
const apiCommitDate = commit.data?.committer?.date || commit.data?.author?.date;
if (apiCommitDate) {
return new Date(apiCommitDate);
}

core.warning(`failed to get commit date for ${sha}, fallback to current date`);
return new Date();
}

0 comments on commit b2dd46b

Please sign in to comment.