Sfoglia il codice sorgente

Backport fixes to maestro-bot scripts

Nate McMaster 7 anni fa
parent
commit
6ea43cb951

+ 2 - 3
scripts/UpdateDependencies.ps1

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

+ 20 - 9
scripts/UpdateDependenciesCoreFx.ps1

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

+ 16 - 9
scripts/common.psm1

@@ -15,7 +15,10 @@ function Invoke-Block([scriptblock]$cmd) {
     # - $?: did the powershell script block throw an error
     # - $?: did the powershell script block throw an error
     # - $lastexitcode: did a windows command executed by the script block end in error
     # - $lastexitcode: did a windows command executed by the script block end in error
     if ((-not $?) -or ($lastexitcode -ne 0)) {
     if ((-not $?) -or ($lastexitcode -ne 0)) {
-        Write-Warning $error[0]
+        if(($error -ne $null))
+        {
+            Write-Warning $error[0]
+        }
         throw "Command failed to execute: $cmd"
         throw "Command failed to execute: $cmd"
     }
     }
 }
 }
@@ -121,9 +124,8 @@ function Ensure-Hub() {
     if (-Not (Test-Path $hubLocation) ) {
     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"
         $source = "https://github.com/github/hub/releases/download/v2.3.0-pre9/hub-windows-amd64-2.3.0-pre9.zip"
         $zipLocation = "$tmpDir\hub.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
         Invoke-WebRequest -OutFile $zipLocation -Uri $source
 
 
@@ -136,11 +138,17 @@ function Ensure-Hub() {
     return $hubLocation
     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
     $hubLocation = Ensure-Hub
 
 
-    Invoke-Block { git push -f https://[email protected]/aspnet/Universe.git $destinationBranch }
-    & $hubLocation pull-request -f -b $baseBranch -h $destinationBranch -m $body
+    Invoke-Block { git push -f https://[email protected]/$headFork/Universe.git $destinationBranch }
+    & $hubLocation pull-request -f -b "${baseFork}:$baseBranch" -h "${headFork}:$destinationBranch" -m $body
 }
 }
 
 
 function Set-GithubInfo(
 function Set-GithubInfo(
@@ -163,8 +171,7 @@ function CommitUpdatedVersions(
 
 
         $subject = "Updating external dependencies"
         $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"
         $body = "$subject`n`n"