Skip to content

Instantly share code, notes, and snippets.

@WimObiwan
Last active August 10, 2017 08:40
Show Gist options
  • Save WimObiwan/e20594ff795e329b0ecb29f031e2b558 to your computer and use it in GitHub Desktop.
Save WimObiwan/e20594ff795e329b0ecb29f031e2b558 to your computer and use it in GitHub Desktop.
$UsefulScriptsDir = 'c:\SourceGIT\Internal\UsefulScripts'
#5.x.x
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.3.3' @('Version-5.3.3','fix-5.3.5')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.3.5' @('Version-5.3.5','fix-5.4.4') # fix-5.4.0 - ... - fix-5.4.3
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.4.0' @('Version-5.4.0','fix-5.4.1')
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.4.1' @('Version-5.4.1','fix-5.4.2')
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.4.2' @('Version-5.4.2','fix-5.4.3')
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.4.3' @('Version-5.4.3','fix-5.4.4')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.4.4' @('Version-5.4.4','fix-5.4.5')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.4.5' @('Version-5.4.5','fix-5.4.6')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.4.6' @('Version-5.4.6','fix-5.4.7')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-5.4.7' @('Version-5.4.7','master')
#10.x.x
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.3.3' @('Version-10.3.3','fix-10.3.5')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.3.5' @('Version-10.3.5','fix-10.4.4') # fix-10.4.0 - ... - fix-10.4.3
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.4.0' @('Version-10.4.0','fix-10.4.1')
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.4.1' @('Version-10.4.1','fix-10.4.2')
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.4.2' @('Version-10.4.2','fix-10.4.3')
#. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.4.3' @('Version-10.4.3','fix-10.4.4')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.4.4' @('Version-10.4.4','fix-10.4.5')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.4.5' @('Version-10.4.5','fix-10.4.6')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.4.6' @('Version-10.4.6','fix-10.4.7')
. $UsefulScriptsDir\BatchMerge.ps1 'fix-10.4.7' @('Version-10.4.7','master')
git push --all
dir "*-$version.md" | ren -NewName { $_.Name -replace '-', '-Old ' }
[CmdletBinding(SupportsShouldProcess)]
param
(
[Parameter(Mandatory = $True)]
[string]$SourceBranch,
[Parameter(Mandatory = $True)]
[string[]]$DestinationBranches
)
$ErrorActionPreference = "Stop"
if ($PSCmdlet.ShouldProcess($SourceBranch, "Merge to $([string]::Join(',', $DestinationBranches))")) {
Write-Verbose "Running: git diff-index --quiet HEAD"
git diff-index --quiet HEAD
if ($LASTEXITCODE -ne 0) {
Write-Error "Your repository contains changes. Stash your changes before doing the BatchMerge."
}
Write-Verbose "Running: git checkout $SourceBranch"
git checkout $SourceBranch; if ($LASTEXITCODE -ne 0) { Write-Error "git" }
Write-Verbose "Running: git pull --ff-only"
git pull --ff-only; if ($LASTEXITCODE -ne 0) { Write-Error "git" }
$DestinationBranches | foreach {
$dest = $_
Write-Verbose "Running: git checkout $dest"
git checkout $dest; if ($LASTEXITCODE -ne 0) { Write-Error "git" }
Write-Verbose "Running: git pull --ff-only"
git pull --ff-only; if ($LASTEXITCODE -ne 0) { Write-Error "git" }
Write-Verbose "Running: git merge $SourceBranch"
git merge $SourceBranch
if ($LASTEXITCODE -ne 0) {
#git merge --abort
Write-Error "Merge of $SourceBranch into $dest failed. Do this merge manually, and restart BatchMerge to do the remaining branches."
}
}
Write-Warning "Merge done. Push the changes to send them to the server."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment