From 305d1821fc242c16442da221347871d686e93411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Elcoro?= Date: Mon, 29 Jun 2015 17:16:58 +0200 Subject: [PATCH 1/2] Environment variable support, custom path support --- Configure-GitFlow.ps1 | 55 +++++++++++++++++++++++++++++++++++++------ xaa | 6 +++++ 2 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 xaa diff --git a/Configure-GitFlow.ps1 b/Configure-GitFlow.ps1 index 209cc11..7bc8708 100644 --- a/Configure-GitFlow.ps1 +++ b/Configure-GitFlow.ps1 @@ -12,16 +12,56 @@ http://github.com/jhoerr/posh-gitflow #> Function Configure-GitFlow -{ - $currentPath = Split-Path ${function:Configure-GitFlow}.File -Parent +{ + Param([string]$customGitPath = "") - # Find all 'PortableGit*' folders in the GitHub for Windows application folder - $gitHubPath = "C:\Users\$env:username\AppData\Local\GitHub" - $portableGitFolders = Get-ChildItem $gitHubPath | ?{ $_.PSIsContainer } | ?{$_.Name -like 'PortableGit*'} + $currentPath = Split-Path ${function:Configure-GitFlow}.File -Parent + + if ($customGitPath -eq "") + { + Write-Host "No custom git path supplied, looking for global git installation" + + $environment = Get-ChildItem Env:Path | Select-Object -First 1 -ExpandProperty "Value" + $gitPath = $environment.Split(';') | Where-Object {$_.Contains("Git")} | Select-Object -First 1; + + if (Test-Path $gitPath) + { + Write-Host "Global git installation found at: $gitPath" + $folders = $gitPath + } + else + { + Write-Host "No global git installation found, looking for PortableGit inside GitHub installation" + # Find all 'PortableGit*' folders in the GitHub for Windows application folder + $gitHubPath = "C:\Users\$env:username\AppData\Local\GitHub" + $portaleGitFolders = Get-ChildItem $gitHubPath | ?{ $_.PSIsContainer } | ?{$_.Name -like 'PortableGit*'} | Join-Path -ChildPath "bin" + + if (Test-Path $portableGitFolders) + { + $folders = $portableGitFolders + } + else + { + Write-Host "No PortableGit found inside GitHub installation" + } + } + } + else + { + if (Test-Path (Join-Path $customGitPath "git.exe")) + { + $folders = @($customGitPath) + } + } + + if ($folders.Length -eq 0) + { + Write-Host "No global Git in Path, no GitHub installation found or no custom path found" + Return + } # Provision the PoSH GitFlow scripts for each instance of PortableGit - foreach ($portableGitFolder in $portableGitFolders){ - $gitPath = (Join-Path (Join-Path $gitHubPath $portableGitFolder.Name) "bin") + foreach ($gitPath in $folders){ Write-Host "Installing extensions to Git binaries in '$gitPath'" -ForegroundColor Green Write-Host "Copying Required supporting binaries" @@ -38,4 +78,5 @@ Function Configure-GitFlow Read-Host } + Configure-GitFlow diff --git a/xaa b/xaa new file mode 100644 index 0000000..1eddb4e --- /dev/null +++ b/xaa @@ -0,0 +1,6 @@ + +Name Value +---- ----- +Path C:\Program Files\ConEmu;C:\Program Files\ConEmu\ConEmu;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows ... + + From 12eea11ee85fd47cb2929bf5b9d753a731c04f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Elcoro?= Date: Thu, 6 Aug 2015 19:18:26 +0200 Subject: [PATCH 2/2] Delete xaa --- xaa | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 xaa diff --git a/xaa b/xaa deleted file mode 100644 index 1eddb4e..0000000 --- a/xaa +++ /dev/null @@ -1,6 +0,0 @@ - -Name Value ----- ----- -Path C:\Program Files\ConEmu;C:\Program Files\ConEmu\ConEmu;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows ... - -