Update UpdateDeps script

This commit is contained in:
Ryan Brandenburg 2018-04-20 10:24:39 -07:00
parent 24accd9457
commit eaefd0be14
2 changed files with 21 additions and 14 deletions

View File

@ -9,7 +9,10 @@ param(
$BuildXml, $BuildXml,
[switch] [switch]
$NoCommit, $NoCommit,
[string[]]$ConfigVars = @() [string]$GithubUpstreamBranch,
[string]$GithubEmail,
[string]$GithubUsername,
[string]$GithubToken
) )
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
@ -18,11 +21,7 @@ Set-StrictMode -Version 1
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not $NoCommit) { if (-not $NoCommit) {
$GitHubEmail = $ConfigVars["GithubEmail"] Set-GitHubInfo $GithubToken $GithubUsername $GithubEmail
$GitHubUsername = $ConfigVars["GithubUsername"]
$GitHubPassword = $ConfigVars["GithubToken"]
Set-GitHubInfo $GitHubPassword $GitHubUsername $GitHubEmail
} }
$depsPath = Resolve-Path "$PSScriptRoot/../build/dependencies.props" $depsPath = Resolve-Path "$PSScriptRoot/../build/dependencies.props"
@ -56,15 +55,23 @@ foreach ($package in $remoteDeps.SelectNodes('//Package')) {
} }
} }
$updatedVars = UpdateVersions $variables $dependencies $depsPath
if (-not $NoCommit) { $currentBranch = Invoke-Block { & git rev-parse --abbrev-ref HEAD }
$body = CommitUpdatedVersions $updatedVars $dependencies $depsPath
$destinationBranch = "dotnetbot/UpdateDeps"
$baseBranch = $ConfigVars["GithubUpstreamBranch"] $destinationBranch = "dotnetbot/UpdateDeps"
Invoke-Block { & git checkout -tb $destinationBranch "origin/$GithubUpstreamBranch" }
if ($body) { try {
CreatePR $baseBranch $destinationBranch $body $GitHubPassword $updatedVars = UpdateVersions $variables $dependencies $depsPath
if (-not $NoCommit) {
$body = CommitUpdatedVersions $updatedVars $dependencies $depsPath
if ($body) {
CreatePR $GithubUpstreamBranch $destinationBranch $body $GithubToken
}
} }
} }
finally {
Invoke-Block { & git checkout $currentBranch }
}

View File

@ -205,7 +205,7 @@ function UpdateVersions([hashtable]$variables, [xml]$dependencies, [string]$deps
} }
if ($updatedVars.Count -gt 0) { if ($updatedVars.Count -gt 0) {
Write-Host -f Cyan "Updating $count version variables in $depsPath" Write-Host -f Cyan "Updating version variables in $depsPath"
SaveXml $dependencies $depsPath SaveXml $dependencies $depsPath
} }
else { else {