Skip to content

Commit 56e3ae9

Browse files
authored
Add days since last commit as of deletion day to tables, center columns
1 parent 415d207 commit 56e3ae9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

.github/workflows/Shared-StaleBranch.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ jobs:
305305
AheadBy = $AheadBy
306306
BehindBy = $BehindBy
307307
DaysSinceLastCommit = $($(Get-Date) - $LastCommitDate).Days
308+
DaysSinceLastCommitOnDeleteDay = $($DeletionDate - $LastCommitDate).Days
308309
ProcessingResult = $Null
309310
BranchCreator = $BranchCreator
310311
}
@@ -452,8 +453,8 @@ jobs:
452453
# Branch processing has completed and, from this point on, reporting is generated.
453454

454455
# Construct the markdown table header that'll be used in the workflow summary.
455-
$TableHeaderRow1 = "| Branch name | Branch creator | Commits ahead by | Commits behind by | Days since last commit | Processing result |"
456-
$TableHeaderRow2 = "|-------------|----------------|------------------|-------------------|------------------------|-------------------|"
456+
$TableHeaderRow1 = "| Branch name | Branch creator | Commits ahead by | Commits behind by | Days since last commit<br>(on $FriendlyDeletionDate) | Processing result |"
457+
$TableHeaderRow2 = "|-------------|----------------|:----------------:|:-----------------:|:----------------------------------------------------:|-------------------|"
457458

458459
# Set job summary and create the "Deleted stale branches" section.
459460
echo "# Stale branch results" >> $env:GITHUB_STEP_SUMMARY
@@ -507,6 +508,10 @@ jobs:
507508

508509
echo "The following branches will be deleted on **$FriendlyDeletionDate** because they will be over $MaxDaysBehind days behind the $DefaultBranch branch on that date. They also contain $MaxCommitsAhead or fewer commits not in the $DefaultBranch branch." >> $env:GITHUB_STEP_SUMMARY
509510
echo "" >> $env:GITHUB_STEP_SUMMARY
511+
echo "**Days since last commit** shows two values:" >> $env:GITHUB_STEP_SUMMARY
512+
echo "- The number of days between the most recent commit and the date the workflow runs." >> $env:GITHUB_STEP_SUMMARY
513+
echo "- The projected number of days between the most recent commit and the scheduled branch-deletion date, $FriendlyDeletionDate, shown in parentheses." >> $env:GITHUB_STEP_SUMMARY
514+
echo "" >> $env:GITHUB_STEP_SUMMARY
510515
echo "> [!IMPORTANT]" >> $env:GITHUB_STEP_SUMMARY
511516
echo "> **If you don't want a branch to be deleted, merge $DefaultBranch into it before $FriendlyDeletionDate.**" >> $env:GITHUB_STEP_SUMMARY
512517
echo "" >> $env:GITHUB_STEP_SUMMARY
@@ -527,11 +532,12 @@ jobs:
527532
$AB = $BranchReport.AheadBy
528533
$BB = $BranchReport.BehindBy
529534
$LC = $BranchReport.DaysSinceLastCommit
535+
$DD = $BranchReport.DaysSinceLastCommitOnDeleteDay
530536
$PR = $BranchReport.ProcessingResult
531537
$BC = $BranchReport.BranchCreator
532538

533-
Write-Host "$PR`: Branch name: $BN. Branch creator: $BC. Ahead by: $AB. Behind by: $BB. Days since last commit: $LC. "
534-
echo "| $BN | [$BC]($GitHubBaseUrl/$BC) | $AB | $BB | $LC | $PR |" >> $env:GITHUB_STEP_SUMMARY
539+
Write-Host "$PR`: Branch name: $BN. Branch creator: $BC. Ahead by: $AB. Behind by: $BB. Days since last commit: $LC. On $FriendlyDeletionDate`: ($DD)."
540+
echo "| $BN | [$BC]($GitHubBaseUrl/$BC) | $AB | $BB | $LC<br>($DD) | $PR |" >> $env:GITHUB_STEP_SUMMARY
535541

536542
}
537543

@@ -565,13 +571,14 @@ jobs:
565571
$AB = $BranchReport.AheadBy
566572
$BB = $BranchReport.BehindBy
567573
$LC = $BranchReport.DaysSinceLastCommit
574+
$DD = $BranchReport.DaysSinceLastCommitOnDeleteDay
568575
$PR = $BranchReport.ProcessingResult
569576
$BC = $BranchReport.BranchCreator
570577

571578
$BranchDiffHtmlUrl = "$($GitHubData.event.repository.html_url)/compare/$DefaultBranch...$($BN)#files_bucket"
572579

573-
Write-Host "$PR`: Branch name: $BN. Branch creator: $BC. Ahead by: $AB. Behind by: $BB. Days since last commit: $LC. "
574-
echo "| [$BN]($BranchDiffHtmlUrl) | [$BC]($GitHubBaseUrl/$BC) | $AB | $BB | $LC | $PR |" >> $env:GITHUB_STEP_SUMMARY
580+
Write-Host "$PR`: Branch name: $BN. Branch creator: $BC. Ahead by: $AB. Behind by: $BB. Days since last commit: $LC. On $FriendlyDeletionDate`: ($DD)."
581+
echo "| [$BN]($BranchDiffHtmlUrl) | [$BC]($GitHubBaseUrl/$BC) | $AB | $BB | $LC<br>($DD) | $PR |" >> $env:GITHUB_STEP_SUMMARY
575582

576583
}
577584

0 commit comments

Comments
 (0)