From bdfd47349722d39b30b978bd57ec4a8986561775 Mon Sep 17 00:00:00 2001 From: anurse Date: Mon, 4 Nov 2013 15:40:34 -0800 Subject: [PATCH] Added scripts to help manage branches --- tools/Clean-Branches.ps1 | 12 +----------- tools/Get-MergedBranches.ps1 | 13 +++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 tools/Get-MergedBranches.ps1 diff --git a/tools/Clean-Branches.ps1 b/tools/Clean-Branches.ps1 index b691627550..a620bd6342 100644 --- a/tools/Clean-Branches.ps1 +++ b/tools/Clean-Branches.ps1 @@ -1,16 +1,6 @@ param([switch]$Force) -$toClean = @( - git branch --merged origin/master -r | - foreach { $_.Trim() } | - where { - ($_ -notmatch "origin/pr/\d+") -and - ($_ -match "origin/(?[A-Za-z0-9-/]*).*") - } | - foreach { $matches.b } | - where { - @("HEAD","master","dev","dev-start","qa","staging") -notcontains $_ - }) +$toClean = & "$PSScriptRoot\Get-MergedBranches.ps1" $pushargs = @($toClean | foreach { ":$_" }) if($Force) { diff --git a/tools/Get-MergedBranches.ps1 b/tools/Get-MergedBranches.ps1 new file mode 100644 index 0000000000..d2a6a4e664 --- /dev/null +++ b/tools/Get-MergedBranches.ps1 @@ -0,0 +1,13 @@ +param([string]$ParentBranch = "master") + +git branch --merged "origin/$ParentBranch" -r | + foreach { $_.Trim() } | + where { $_ -like "origin*" } | + where { + ($_ -notlike "origin/pr*") -and + ($_ -notlike "origin/HEAD*") -and + (@("origin/master","origin/dev","origin/staging","origin/dev-start","origin/qa") -notcontains $_) + } | + foreach { + $_.Substring("origin/".Length) + } \ No newline at end of file