Backport fixes to maestro-bot scripts

This commit is contained in:
Nate McMaster 2018-05-03 19:25:11 -07:00
parent 9f0c208871
commit 6ea43cb951
No known key found for this signature in database
GPG Key ID: A778D9601BD78810
3 changed files with 38 additions and 21 deletions

View File

@ -7,8 +7,7 @@
param(
[Parameter(Mandatory = $true)]
$BuildXml,
[switch]
$NoCommit,
[switch]$NoCommit,
[string]$GithubUpstreamBranch,
[string]$GithubEmail,
[string]$GithubUsername,
@ -68,7 +67,7 @@ try {
$body = CommitUpdatedVersions $updatedVars $dependencies $depsPath
if ($body) {
CreatePR $GithubUpstreamBranch $destinationBranch $body $GithubToken
CreatePR "aspnet" $GithubUsername $GithubUpstreamBranch $destinationBranch $body $GithubToken
}
}
}

View File

@ -1,6 +1,7 @@
[CmdletBinding()]
param(
[switch]$NoCommit,
[string]$GithubEmail,
[string]$GithubUsername,
[string]$GithubToken
@ -22,6 +23,9 @@ $coreFxRepo = "dotnet/corefx"
$coreSetupVersions = "$githubRaw/$versionsRepo/$versionsBranch/build-info/$coreSetupRepo/master/Latest_Packages.txt"
$tempDir = "$PSScriptRoot/../obj"
mkdir -Path $tempDir -ErrorAction Ignore
$localCoreSetupVersions = "$tempDir/coresetup.packages"
Write-Host "Downloading $coreSetupVersions to $localCoreSetupVersions"
Invoke-WebRequest -OutFile $localCoreSetupVersions -Uri $coreSetupVersions
@ -103,21 +107,28 @@ $depsPath = Resolve-Path "$PSScriptRoot/../build/dependencies.props"
Write-Host "Loading deps from $depsPath"
[xml] $dependencies = LoadXml $depsPath
$remote = "origin"
$baseBranch = "release/2.1"
if (-not $NoCommit) {
$baseBranch = "release/2.1"
Invoke-Block { & git fetch origin }
$currentBranch = Invoke-Block { & git rev-parse --abbrev-ref HEAD }
$destinationBranch = "rybrande/UpgradeDepsTest"
$currentBranch = Invoke-Block { & git rev-parse --abbrev-ref HEAD }
$destinationBranch = "dotnetbot/UpdateCoreFxDeps"
Invoke-Block { & git checkout -tb $destinationBranch "origin/$baseBranch" }
}
Invoke-Block { & git checkout -tb $destinationBranch "$remote/$baseBranch" }
try {
$updatedVars = UpdateVersions $variables $dependencies $depsPath
$body = CommitUpdatedVersions $updatedVars $dependencies $depsPath
if (-not $NoCommit) {
$body = CommitUpdatedVersions $updatedVars $dependencies $depsPath
if ($body) {
CreatePR $baseBranch $destinationBranch $body $GithubToken
if ($body) {
CreatePR "aspnet" $GithubUsername $baseBranch $destinationBranch $body $GithubToken
}
}
}
finally {
Invoke-Block { & git checkout $currentBranch }
if (-not $NoCommit) {
Invoke-Block { & git checkout $currentBranch }
}
}

View File

@ -15,7 +15,10 @@ function Invoke-Block([scriptblock]$cmd) {
# - $?: did the powershell script block throw an error
# - $lastexitcode: did a windows command executed by the script block end in error
if ((-not $?) -or ($lastexitcode -ne 0)) {
Write-Warning $error[0]
if(($error -ne $null))
{
Write-Warning $error[0]
}
throw "Command failed to execute: $cmd"
}
}
@ -121,9 +124,8 @@ function Ensure-Hub() {
if (-Not (Test-Path $hubLocation) ) {
$source = "https://github.com/github/hub/releases/download/v2.3.0-pre9/hub-windows-amd64-2.3.0-pre9.zip"
$zipLocation = "$tmpDir\hub.zip"
if(-not (Test-Path $zipLocation)) {
New-Item -ItemType directory -Path $tmpDir
}
mkdir -Path $tmpDir -ErrorAction Ignore | Out-Null
Invoke-WebRequest -OutFile $zipLocation -Uri $source
@ -136,11 +138,17 @@ function Ensure-Hub() {
return $hubLocation
}
function CreatePR([string]$baseBranch, [string]$destinationBranch, [string]$body, [string]$gitHubToken) {
function CreatePR(
[string]$baseFork,
[string]$headFork,
[string]$baseBranch,
[string]$destinationBranch,
[string]$body,
[string]$gitHubToken) {
$hubLocation = Ensure-Hub
Invoke-Block { git push -f https://$gitHubToken@github.com/aspnet/Universe.git $destinationBranch }
& $hubLocation pull-request -f -b $baseBranch -h $destinationBranch -m $body
Invoke-Block { git push -f https://$gitHubToken@github.com/$headFork/Universe.git $destinationBranch }
& $hubLocation pull-request -f -b "${baseFork}:$baseBranch" -h "${headFork}:$destinationBranch" -m $body
}
function Set-GithubInfo(
@ -163,8 +171,7 @@ function CommitUpdatedVersions(
$subject = "Updating external dependencies"
# Have to pipe null so that the output from this doesn't end up as part of the return value
$null = Invoke-Block { & git commit -m $subject }
Invoke-Block { & git commit -m $subject } | Out-Null
$body = "$subject`n`n"