You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/Shared-StaleBranch.yml
+69-31Lines changed: 69 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -116,6 +116,8 @@ jobs:
116
116
$WatchListCount = 0
117
117
$DataLossCount = 0
118
118
$DataLossBlockedCount = 0
119
+
$RetrieveBranchDataErrorCount = 0
120
+
$RetrieveBranchDataError = $False
119
121
120
122
# Block the script from running if Ahead by is greater than 0 when maximum branch age is less than 90. Doing this could result in loss of data that may still be
121
123
# wanted. Do not change the values unless you accept the high risk of unwanted data loss.
Write-Host " Skipped. Branch exceeds `"ahead by`" limit of $MaxCommitsAhead."
190
-
191
-
$ReportBranchList += ">>> Branch watch list <<< $BranchName exceeds maximum age but has outstanding commits that exceed maximum Ahead By limit. Branch protected: $ProtectedBranch. Ahead by: $AheadBy. Behind by $BehindBy. Days since last commit: $($($(Get-Date) - $LastCommitDate).Days)."
Write-Host " Skipped. Branch exceeds `"ahead by`" limit of $MaxCommitsAhead."
208
207
209
-
$ReportBranchList += "$ReportOnlyString $BranchName deleted. Branch protected: $ProtectedBranch. Ahead by: $AheadBy. Behind by $BehindBy. Days since last commit: $($($(Get-Date) - $LastCommitDate).Days)."
208
+
$ReportBranchList += ">>> Branch watch list <<< $BranchName exceeds maximum age but has outstanding commits that exceed maximum Ahead By limit. Branch protected: $ProtectedBranch. Ahead by: $AheadBy. Behind by $BehindBy. Days since last commit: $($($(Get-Date) - $LastCommitDate).Days)."
210
209
211
-
$DeleteBranchCount++
210
+
$WatchListCount++
212
211
213
-
} Else {
214
-
215
-
If ($AllowDataLoss) {
212
+
continue
213
+
214
+
}
215
+
216
+
If ($AheadBy -eq 0) {
216
217
217
-
Write-Host " $ReportOnlyString Delete branch $BranchName with data loss"
$ReportBranchList += "$ReportOnlyString !!! DATA LOSS !!! $BranchName deleted. Branch protected: $ProtectedBranch. Ahead by: $AheadBy. Behind by $BehindBy. Days since last commit: $($($(Get-Date) - $LastCommitDate).Days). "
226
+
$ReportBranchList += "$ReportOnlyString $BranchName deleted. Branch protected: $ProtectedBranch. Ahead by: $AheadBy. Behind by $BehindBy. Days since last commit: $($($(Get-Date) - $LastCommitDate).Days). "
226
227
227
228
$DeleteBranchCount++
228
-
$DataLossCount++
229
-
229
+
230
230
} Else {
231
231
232
-
Write-Host " $ReportOnlyString Branch $BranchName was marked for deletion with data loss but data loss flag is disabled."
232
+
If ($AllowDataLoss) {
233
+
234
+
Write-Host " $ReportOnlyString Delete branch $BranchName with data loss"
233
235
234
-
$ReportBranchList += "$ReportOnlyString *** DATA LOSS BLOCKED *** $BranchName was marked for deletion with data loss but the data loss flag is disabled. Branch protected: $ProtectedBranch. Ahead by: $AheadBy. Behind by $BehindBy. Days since last commit: $($($(Get-Date) - $LastCommitDate).Days)."
$ReportBranchList += "$ReportOnlyString !!! DATA LOSS !!! $BranchName deleted. Branch protected: $ProtectedBranch. Ahead by: $AheadBy. Behind by $BehindBy. Days since last commit: $($($(Get-Date) - $LastCommitDate).Days). "
243
+
244
+
$DeleteBranchCount++
245
+
$DataLossCount++
246
+
247
+
} Else {
248
+
249
+
Write-Host " $ReportOnlyString Branch $BranchName was marked for deletion with data loss but data loss flag is disabled."
250
+
251
+
$ReportBranchList += "$ReportOnlyString *** DATA LOSS BLOCKED *** $BranchName was marked for deletion with data loss but the data loss flag is disabled. Branch protected: $ProtectedBranch. Ahead by: $AheadBy. Behind by $BehindBy. Days since last commit: $($($(Get-Date) - $LastCommitDate).Days)."
252
+
253
+
$DataLossBlockedCount++
254
+
255
+
} # AllowDataLoss If
237
256
238
-
} # AllowDataLoss If
257
+
} # AheadBy If
258
+
259
+
} Else {
239
260
240
-
} # AheadBy If
261
+
Write-Host " ERROR - One or more variables doesn't contain a valid data type. CompareData: $($CompareData). AheadBy: $($AheadBy -is [int]). BehindBy: $($BehindBy -is [int]). LastCommitDate: $($LastCommitDate -is [datetime]). Skipping."
0 commit comments