Skip to content

Commit a5df583

Browse files
committed
Added Test-GitRemote
1 parent 34e8153 commit a5df583

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

git/Test-GitRemote.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
function Test-GitRemote {
2+
<#
3+
.SYNOPSIS
4+
Scans git directories and displays remotes information
5+
6+
.DESCRIPTION
7+
Scans git directories and displays git remotes information with verbose option.
8+
It provides following information:
9+
10+
origin git@github.com:alan-null/test.git (fetch)
11+
origin git@github.com:alan-null/test.git (fetch)
12+
13+
.PARAMETER DirectoryPath
14+
Root dir containing other git repo folders
15+
16+
.EXAMPLE
17+
Test-GitRemote
18+
Iterates through folders in a current directory and displays git status of each repo
19+
20+
.EXAMPLE
21+
Test-GitRemote c:\repo
22+
Iterates through folders from a 'c:\repo' directory and displays git status of each repo
23+
#>
24+
25+
[CmdletBinding()]
26+
param(
27+
[Parameter(Mandatory = $false, Position = 0)]
28+
[string]$DirectoryPath
29+
)
30+
31+
# begin {
32+
# Import-Module posh-git
33+
# }
34+
35+
process {
36+
if (!$DirectoryPath) {
37+
$DirectoryPath = Get-Location
38+
}
39+
$revertPath = Get-Location
40+
41+
try {
42+
Get-ChildItem $DirectoryPath | ? { $_.PSIsContainer } | % {
43+
$dir = $_.FullName
44+
45+
Set-Location $dir
46+
$git = Get-GitStatus
47+
48+
if ($git.GitDir) {
49+
Write-Host $dir -ForegroundColor Green
50+
git remote -v
51+
Write-Host ""
52+
}
53+
}
54+
}
55+
finally {
56+
Set-Location $revertPath
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)