-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-branches-all-repo.ps1
41 lines (32 loc) · 1.04 KB
/
get-branches-all-repo.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
param()
function Get-AllFolders ()
{
$folderarray = Get-ChildItem -Directory -Recurse
ForEach-Object {
Get-AllRepos
}
}
function Get-AllRepos ()
{
Get-ChildItem -Recurse -Depth 2 -Force |
Where-Object { $_.Mode -match "h" -and $_.FullName -like "*\.git" } |
ForEach-Object {
$dir = Get-Item (Join-Path $_.FullName "../")
Push-Location $dir
"Fetching $($dir.Name)"
function Get-AllRemoteBranches {
Invoke-Expression "git branch -r" `
| ForEach-Object { $_ -Match "origin\/(?'name'\S+)" } `
| ForEach-Object { Out-Null; $matches['name'] }
}
function Get-AllBranches {
Get-AllRemoteBranches `
| ForEach-Object { Invoke-Expression "git checkout $_" } `
| ForEach-Object { Invoke-Expression "git pull" }
}
Get-AllBranches
Invoke-Expression "git checkout master"
Pop-Location
}
}
Get-AllFolders