-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathghallrm.ps1
58 lines (46 loc) · 983 Bytes
/
ghallrm.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<#
.SYNOPSIS
Use GHRM in ALL repos
.PARAMETER Repos
Directory that has subfolders with repos
.EXAMPLE
PS> ghallrm ~/bin
#>
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter(Mandatory=$true)]
[string] $Repos
)
$script:ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
function GitBranchOffDefault {
try {
$current = Get-GitBranch.ps1 2> $null
} catch {
Write-Verbose "Skipping $dir, not a git repo"
return ""
}
$default = Get-GitDefaultBranch
if ($current -ne $default) {
return $current
}
# MAYBE also run git status -s to see if there are any changes
}
foreach ($dir in Get-ChildItem $Repos -Directory) {
Push-Location $dir
$offDefault = GitBranchOffDefault
if (!$offDefault) {
Pop-Location
continue
}
Write-Verbose "Process $dir"
""
"$($dir.Name): on branch $offDefault"
try {
git status -s
ghrm
} catch {
Write-Warning "Not quitting on error $_"
}
Pop-Location
}