diff --git a/scripts/UpdateDependencies.ps1 b/scripts/UpdateDependencies.ps1 index 7146693e5b..8708eee27b 100755 --- a/scripts/UpdateDependencies.ps1 +++ b/scripts/UpdateDependencies.ps1 @@ -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 } } } diff --git a/scripts/UpdateDependenciesCoreFx.ps1 b/scripts/UpdateDependenciesCoreFx.ps1 index f52f963f70..3a4e2b9903 100644 --- a/scripts/UpdateDependenciesCoreFx.ps1 +++ b/scripts/UpdateDependenciesCoreFx.ps1 @@ -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 } + } } diff --git a/scripts/common.psm1 b/scripts/common.psm1 index c2d2e2a8ca..e99d9a0881 100644 --- a/scripts/common.psm1 +++ b/scripts/common.psm1 @@ -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"