Skip to content

Commit

Permalink
fix: handle edge case of branch with no commits (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 authored May 20, 2024
1 parent 58a48c9 commit 018c2b2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions action-audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ async function run() {
if (ACTION_TYPE === Actions.UNRELEASED) {
text += buildUnreleasedCommitsMessage(branch, commits, initiatedBy);
const earliestCommit = commits[0];
const unreleasedDays = Math.floor(
(Date.now() - new Date(earliestCommit.committer.date).getTime()) /
MILLISECONDS_PER_DAY,
);
if (unreleasedDays > UNRELEASED_DAYS_WARN_THRESHOLD) {
text += `\n ⚠️ *There have been unreleased commits on \`${branch}\` for ${unreleasedDays} days!*`;
if (earliestCommit !== undefined) {
const unreleasedDays = Math.floor(
(Date.now() - new Date(earliestCommit.committer.date).getTime()) /
MILLISECONDS_PER_DAY,
);
if (unreleasedDays > UNRELEASED_DAYS_WARN_THRESHOLD) {
text += `\n ⚠️ *There have been unreleased commits on \`${branch}\` for ${unreleasedDays} days!*`;
}
}
} else if (ACTION_TYPE === Actions.NEEDS_MANUAL) {
text += buildNeedsManualPRsMessage(
Expand Down

0 comments on commit 018c2b2

Please sign in to comment.