Push repos if they build
This commit is contained in:
parent
3113d9573c
commit
bbf5d142ed
|
|
@ -54,21 +54,17 @@ if ($GitAuthorEmail) {
|
||||||
|
|
||||||
Push-Location $ModuleDirectory
|
Push-Location $ModuleDirectory
|
||||||
try {
|
try {
|
||||||
# Init all submodules
|
|
||||||
Write-Verbose "Updating submodules..."
|
|
||||||
Invoke-Block { & git submodule update --init } | Out-Null
|
|
||||||
Write-Verbose "Submodules updated."
|
|
||||||
|
|
||||||
$update_errors = @()
|
$build_errors = @()
|
||||||
|
# Get-Submodules also update --init's them
|
||||||
$submodules = Get-Submodules $RepoRoot
|
$submodules = Get-Submodules $RepoRoot
|
||||||
$updated_submodules = @()
|
|
||||||
foreach ($submodule in $submodules) {
|
foreach ($submodule in $submodules) {
|
||||||
Push-Location $submodule.path
|
Push-Location $submodule.path
|
||||||
try {
|
try {
|
||||||
$depsFile = Join-Path (Join-Path $($submodule.path) "build") "dependencies.props"
|
$depsFile = Join-Path (Join-Path $($submodule.path) "build") "dependencies.props"
|
||||||
|
|
||||||
if (!(Test-Path $depsFile)) {
|
if (!(Test-Path $depsFile)) {
|
||||||
Write-Warning "No build\dependencies.props file exists for $($submodule.module)."
|
Write-Warning "No build\dependencies.props file exists for '$($submodule.module)'."
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,6 +80,7 @@ try {
|
||||||
|
|
||||||
Invoke-Block { & git @gitConfigArgs add $depsFile $koreBuildLock }
|
Invoke-Block { & git @gitConfigArgs add $depsFile $koreBuildLock }
|
||||||
|
|
||||||
|
# If there were any changes test and push.
|
||||||
& git diff --cached --quiet ./
|
& git diff --cached --quiet ./
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Invoke-Block { & git @gitConfigArgs commit --quiet -m "Update dependencies.props`n`n[auto-updated: dependencies]" @GitCommitArgs }
|
Invoke-Block { & git @gitConfigArgs commit --quiet -m "Update dependencies.props`n`n[auto-updated: dependencies]" @GitCommitArgs }
|
||||||
|
|
@ -91,7 +88,30 @@ try {
|
||||||
# Prepare this submodule for push
|
# Prepare this submodule for push
|
||||||
$sshUrl = "git@github.com:aspnet/$($submodule.module)"
|
$sshUrl = "git@github.com:aspnet/$($submodule.module)"
|
||||||
Invoke-Block { & git remote set-url --push origin $sshUrl }
|
Invoke-Block { & git remote set-url --push origin $sshUrl }
|
||||||
$updated_submodules += $submodule
|
|
||||||
|
# Test the submodule
|
||||||
|
try {
|
||||||
|
Invoke-Block { & .\run.ps1 default-build }
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "Error in $($submodule.module): $_"
|
||||||
|
$build_errors += @{
|
||||||
|
Repo = $submodule.module
|
||||||
|
Message = $_
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# Push the changes
|
||||||
|
if (-not $NoPush -and ($Force -or ($PSCmdlet.ShouldContinue("Pushing updates to repos.", 'Push the changes to these repos?')))) {
|
||||||
|
try {
|
||||||
|
Invoke-Block { & git @gitConfigArgs push origin HEAD:$submodule.branch}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "Error in pushing $($submodule.module): $_"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "No changes in $($submodule.module)"
|
Write-Host "No changes in $($submodule.module)"
|
||||||
|
|
@ -99,45 +119,6 @@ try {
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Warning "Error in $($submodule.module)"
|
Write-Warning "Error in $($submodule.module)"
|
||||||
$update_errors += @{
|
|
||||||
Repo = $submodule.module
|
|
||||||
Message = $_
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
Pop-Location
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($update_errors.Count -gt 0 ) {
|
|
||||||
foreach ($update_error in $update_errors) {
|
|
||||||
if ($update_error.Message -eq $null) {
|
|
||||||
Write-Error "Error was null."
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Error "$($update_error.Repo) error: $($update_error.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw 'Failed to update'
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Verbose "All updates successful!"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Build each submodule to verify that it works after the update
|
|
||||||
$build_errors = @()
|
|
||||||
foreach ($submodule in $updated_submodules) {
|
|
||||||
Push-Location $submodule.path
|
|
||||||
try {
|
|
||||||
Invoke-Block { & .\run.ps1 default-build }
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "Error in $($submodule.module): $_"
|
|
||||||
$build_errors += @{
|
|
||||||
Repo = $submodule.module
|
|
||||||
Message = $_
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
@ -147,27 +128,6 @@ try {
|
||||||
if ($build_errors.Count -gt 0 ) {
|
if ($build_errors.Count -gt 0 ) {
|
||||||
throw "Failed to build"
|
throw "Failed to build"
|
||||||
}
|
}
|
||||||
|
|
||||||
$shortMessage = "Pushing updates to repos."
|
|
||||||
if (-not $NoPush -and ($Force -or ($PSCmdlet.ShouldContinue($shortMessage, 'Push the changes to these repos?')))) {
|
|
||||||
$push_errors = @()
|
|
||||||
foreach ($submodule in $updated_submodules) {
|
|
||||||
Push-Location $submodule.path
|
|
||||||
try {
|
|
||||||
Invoke-Block { & git @gitConfigArgs push origin HEAD:$submodule.branch}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$push_errors += $_
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
Pop-Location
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($push_errors.Count -gt 0 ) {
|
|
||||||
throw 'Failed to push'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue