-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0425fdc
commit 6f7eb91
Showing
4 changed files
with
143 additions
and
28 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
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 |
---|---|---|
@@ -1,38 +1,44 @@ | ||
param( | ||
$RepoOwner = "Azure", | ||
$RepoOwner, | ||
$RepoName, | ||
$BranchPrefix = "sync-eng/common", | ||
$BranchPrefix, | ||
$WorkingDirectory, | ||
$AuthToken | ||
) | ||
|
||
. "${PSScriptRoot}\logging.ps1" | ||
. "${PSScriptRoot}\Invoke-GitHub-API.ps1" | ||
. "${PSScriptRoot}\Invoke-GitHub-API.ps1" -AuthToken $AuthToken | ||
|
||
git clone "https://github.com/$RepoOwner/$RepoName" | ||
pushd $WorkingDirectory | ||
git clone https://github.com/$RepoOwner/$RepoName.git | ||
pushd $RepoName | ||
$syncBranches = (git branch --remote).where{$_ -like "*origin/$BranchPrefix*"} | ||
$syncBranches = (git branch --remote).where{ $_ -like "*origin/$BranchPrefix*" } | ||
|
||
Write-Host "Repo Name $RepoName" | ||
LogDebug "Operating on Repo [ $RepoName ]" | ||
foreach ($branch in $syncBranches) | ||
{ | ||
try { | ||
$branchName = $branch.Trim() | ||
$branchName = ($branch.Trim()).Replace("origin/","") | ||
$head = "${RepoOwner}/${RepoName}:${branchName}" | ||
LogDebug "Operating on branch [ $branchName ]" | ||
$response = ListPullRequests -RepoOwner $RepoOwner -RepoName $RepoName -head $head | ||
} | ||
catch | ||
{ | ||
LogError "ListPullRequests failed with exception:`n$_" | ||
exit 1 | ||
} | ||
Write-Host "Response Count $($Response.Count)" | ||
if ($Response.Count -eq 0) | ||
|
||
if ($response.Count -eq 0) | ||
{ | ||
# Delete branch here | ||
#git push origin --delete "sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)" | ||
#if ($lastExitCode -ne 0) { | ||
# Write-Host "Failed to delete [sync-${{ parameters.DirectoryToSync }}-$(System.PullRequest.SourceBranch)-$(System.PullRequest.PullRequestNumber)] branch in ${{ repo }}" | ||
# exit 1 | ||
#} | ||
LogDebug "Branch [ $branchName ] in repo [ $RepoName ] has no associated Pull Request. Deleting Branch" | ||
git push origin --delete $branchName | ||
if ($lastExitCode -ne 0) { | ||
Write-Host "Failed to delete branch [ $branchName ] in repo [ $RepoName ]" | ||
exit 1 | ||
} | ||
} | ||
} | ||
|
||
popd | ||
popd |
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
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