jhoerr / posh-gitflow

A set of scripts to incorporate PoSH GitFlow extensions with posh-git, the PowerShell environment for git.
26 stars 8 forks source link

If GitHub not installed, not possible to install #8

Open sirbabyface opened 9 years ago

sirbabyface commented 9 years ago

I don't have github installed. I got an error. I've posh-git installed and working nicely. This is the error I got:

Get-ChildItem : Cannot find path 'C:\Users\<username>\AppData\Local\GitHub' because it does not exist.
At E:\Repos\posh-gitflow\Configure-GitFlow.ps1:20 char:24
+     $portableGitFolders = Get-ChildItem $gitHubPath | ?{ $_.PSIsContainer } | ?{$_. ...
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\<username>\AppData\Local\GitHub:String) [Get-ChildItem], I
   temNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

Should GitHub be necessary?

jhoerr commented 9 years ago

Whoops -- fat-fingered the 'Close' button. I think this might just be a path issue. Where are git and posh-git installed for you?

sirbabyface commented 9 years ago

posh-git: C:\Users\Documents\WindowsPowerShell\Modules\posh-git git: C:\Program Files (x86)\Git

But only the C:\Program Files (x86)\Git\cmd is in the path, should I also include the C:\Program Files (x86)\Git\bin

I've tried the above, but the problem remains.

ielcoro commented 9 years ago

In my case I only have a global git installation, no GitHub installed, so I changed the script to look in environment variables for the git installation directory, accept a custom path parameter or look for GitHub installation:

Function Configure-GitFlow
{
    Param([string]$customGitPath = "")

    $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 ($gitPath in $folders){
        Write-Host "Installing extensions to Git binaries in '$gitPath'" -ForegroundColor Green

        Write-Host "Copying Required supporting binaries"
        Copy-Item (Join-Path $currentPath "Dependencies\*.*") -Destination $gitPath -Verbose

        Write-Host "Copying GitFlow extensions"
        Copy-Item (Join-Path $currentPath "GitFlowExtensions\**") -Destination $gitPath -Verbose

        Write-Host "Copying Git components"
        Copy-Item (Join-Path $gitPath "libiconv-2.dll") -Destination (Join-Path $gitPath "libiconv2.dll") -Verbose
    }

    Write-Host "Press Any Key to finish"
    Read-Host
}

Configure-GitFlow

I can make a Pull Request if you like it

sirbabyface commented 9 years ago

It work fine. Just make sure it is run in Administrator mode.

I think you should make a Pull request.

ielcoro commented 9 years ago

Great to see working to others, will prepare the PR tonight or tomorrow morning :-)

rodolfoprr commented 9 years ago

@ielcoro thanks for your Configure-GitFlow file! Like @sirbabyface, it worked fine in my computer.

Just in "Copying Git components" that I needed to copy manually libiconv-2.dll from "C:\Program Files\Git\mingw64\bin" to "C:\Program Files\Git\cmd". I used Git for Windows 2.5.1, I don't know if was because of it.

ielcoro commented 9 years ago

@rodolfoprr Glado it worked.

About the issue with libiconv-2.dll,you are right it's caused by Git For Windows 2x installations. They changed the folder layout from the 1x versions. Will look into it.

ielcoro commented 9 years ago

@rodolfoprr Did you try to run "git flow init" on a repo? I´m getting "Culd not determine getopt version" message and after some digging I found that Git For Windows 2x now ships with libicon-v2 version 1.14 that breaks getopt.exe , that is linked against to the older 1.9 versin

rodolfoprr commented 9 years ago

@ielcoro yes, and it worked. My libiconv-2.dll version is 1.14 and getopt.exe version is 2.14.3192.42783.

ielcoro commented 9 years ago

Ummm.. mine is the same versions and crash badly. I can make it working only with libiconv-2 1.9 version.

The problem is that if true, the right version of libiconv2 should be shipped in the dependecies folder. I see it as the right thing to do, like it's being done with getopt.exe and libintl3.dll but I´m not sure how the mantainers think about it.