Skip to content

Commit

Permalink
Update Delete-RemoteBranches.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
sima-zhu authored and azure-sdk committed Apr 28, 2022
1 parent 81be9b4 commit 7105e7f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions eng/common/scripts/Delete-RemoteBranches.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ foreach ($res in $responses)
continue
}
$branch = $res.ref
$branchName = $branch.Replace("refs/heads/","")
try {
$branchName = $branch.Replace("refs/heads/","")
$head = "${RepoId}:${branchName}"
LogDebug "Operating on branch [ $branchName ]"
$pullRequests = Get-GitHubPullRequests -RepoId $RepoId -State "all" -Head $head -AuthToken $AuthToken
Expand Down Expand Up @@ -62,11 +62,11 @@ foreach ($res in $responses)
try {
$commitDate = Get-GithubReferenceCommitDate -commitUrl $res.object.url -AuthToken $AuthToken
if (!$commitDate -or ($commitDate -gt $LastCommitOlderThan)) {
LogDebug "No last commit date or the branch $branch last commit date [$commitDate] is newer than the date $LastCommitOlderThan. Skipping."
LogDebug "No last commit date or the branch $branch last commit date [ $commitDate ] is newer than the date $LastCommitOlderThan. Skipping."
continue
}

LogDebug "Branch [ $branch ] in repo [ $RepoId ] has a last commit date $commitDate that is older than $LastCommitOlderThan. "
LogDebug "Branch [ $branchName ] in repo [ $RepoId ] has a last commit date [ $commitDate ] that is older than $LastCommitOlderThan. "
}
catch {
LogError "Get-GithubReferenceCommitDate failed with exception:`n$_"
Expand All @@ -75,7 +75,7 @@ foreach ($res in $responses)
}
try {
Remove-GitHubSourceReferences -RepoId $RepoId -Ref $branch -AuthToken $AuthToken
LogDebug "The branch $branch in $RepoId has been deleted."
LogDebug "The branch [ $branchName ] in [ $RepoId ] has been deleted."
}
catch {
LogError "Remove-GitHubSourceReferences failed with exception:`n$_"
Expand Down

0 comments on commit 7105e7f

Please sign in to comment.