forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync eng/common directory with azure-sdk-tools for PR 1088 (Azure#15952)
Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#1088 See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/README.md#workflow)
- Loading branch information
1 parent
4829e35
commit fdbb51e
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
param( | ||
$RepoOwner, | ||
$RepoName, | ||
$BranchPrefix, | ||
$AuthToken | ||
) | ||
|
||
. "${PSScriptRoot}\common.ps1" | ||
|
||
LogDebug "Operating on Repo [ $RepoName ]" | ||
try{ | ||
$branches = (List-References -RepoOwner $RepoOwner -RepoName $RepoName -Ref "heads/$BranchPrefix").ref | ||
} | ||
catch { | ||
LogError "List-References failed with exception:`n$_" | ||
exit 1 | ||
} | ||
|
||
foreach ($branch in $branches) | ||
{ | ||
try { | ||
$branchName = $branch.Replace("refs/heads/","") | ||
$head = "${RepoOwner}/${RepoName}:${branchName}" | ||
LogDebug "Operating on branch [ $branchName ]" | ||
$pullRequests = List-PullRequests -RepoOwner $RepoOwner -RepoName $RepoName -head $head | ||
} | ||
catch | ||
{ | ||
LogError "List-PullRequests failed with exception:`n$_" | ||
exit 1 | ||
} | ||
|
||
if ($pullRequests.Count -eq 0) | ||
{ | ||
LogDebug "Branch [ $branchName ] in repo [ $RepoName ] has no associated Pull Request. Deleting Branch" | ||
try{ | ||
Delete-References -RepoOwner $RepoOwner -RepoName $RepoName -Ref ($branch.Remove(0,5)) -AuthToken $AuthToken | ||
} | ||
catch { | ||
LogError "Delete-References failed with exception:`n$_" | ||
exit 1 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters