Created
February 28, 2019 12:19
-
-
Save DorukUlucay/4c4672b6f1f2376ae1cfc4e5b0ca5433 to your computer and use it in GitHub Desktop.
PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get current branches of dirs in a dir | |
function isAGitDir() { | |
if ((Test-Path ".git") -eq $TRUE) { | |
return $TRUE | |
} | |
return $FALSE | |
} | |
function gitCheck($path) { | |
$table = New-Object system.Data.DataTable “theTable” | |
$col1 = New-Object system.Data.DataColumn Directory, ([string]) | |
$col2 = New-Object system.Data.DataColumn Branch, ([string]) | |
$table.columns.add($col1) | |
$table.columns.add($col2) | |
if (!$path) { | |
cd \git | |
} | |
else { | |
cd $path | |
} | |
foreach ($dir in ls -directory) { | |
cd $dir.name | |
$row = $table.NewRow() | |
$row.Directory = $dir.name | |
$isAGitDir = isAGitDir; | |
if ($isAGitDir) { | |
$branch = git rev-parse --abbrev-ref HEAD | |
$row.Branch = $branch | |
} | |
else { | |
$row.Branch = "NOT A GIT DIR" | |
} | |
$table.Rows.Add($row) | |
cd .. | |
} | |
cls | |
$table | format-table -AutoSize | |
} | |
ECHO "Retrieving the info..." | |
gitCheck | |
Read-Host -Prompt "Press Enter to exit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment