Skip to content

Commit

Permalink
add a warning message if there is room in the summary prior to cutoff
Browse files Browse the repository at this point in the history
  • Loading branch information
elireisman committed Sep 16, 2024
1 parent 293ccdb commit 6aacbe0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,21 @@ export function addScannedFiles(changes: Changes): void {
let trunc_at = -1

for (const [index, entry] of manifests.entries()) {
sf_size += entry.length
if (sf_size >= MAX_SCANNED_FILES_BYTES && trunc_at < 0) {
if (sf_size + entry.length >= MAX_SCANNED_FILES_BYTES) {
trunc_at = index
break
}
sf_size += entry.length
}

if (trunc_at >= 0) {
// truncate the manifests list if it will overflow the summary output
manifests.slice(0, trunc_at)
// if there's room between cutoff size and list size, add a warning
const size_diff = MAX_SCANNED_FILES_BYTES - sf_size
if (size_diff < 12) {
manifests.push('(truncated)')
}
}

core.summary.addHeading('Scanned Files', 2).addList(manifests)
Expand Down

0 comments on commit 6aacbe0

Please sign in to comment.