-
-
Notifications
You must be signed in to change notification settings - Fork 48
Fix #80 Get-BuildVariable breaks if git is aliased #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,13 +69,13 @@ function Get-BuildVariables { | |
| } | ||
| $true | ||
| })] | ||
| $GitPath = 'git' | ||
| $GitPath | ||
| ) | ||
|
|
||
| $Path = ( Resolve-Path $Path ).Path | ||
| $Environment = Get-Item ENV: | ||
| if(!$PSboundParameters.ContainsKey('GitPath')) { | ||
| $GitPath = (Get-Command $GitPath -ErrorAction SilentlyContinue)[0].Path | ||
| $GitPath = (Get-ChildItem ($env:PATH -split ';') -filter git.exe -ErrorAction SilentlyContinue | Select-Object -First 1).Fullname | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to fix the fact that git.exe is hard coded here. I will either need to change the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I've changed my mind on this. If the user provides a git path they should be providing a full path to the git executable. If they provide anything at all this variable is given directly to the Process Start info Filename Parameter anyway, so if they do something like provide an input that it can't use, it will already fail. If the user does not provide input to the $GitPath parameter, we already know conclusively that we want to search for git.exe. We aren't searching for git.com or git.bat, or anything like that. This says to me that it is safe to simply leave the $GitPath parameter optional, and there is no need to provide a default value.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hiyo! @gaelcolas has an old PR in one of my repos for a similar thing, looking to resolve just
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot about this PR for a while, and suddenly I get a notice that there was a comment. If @gaelcolas wants to link me the PR that would be great. Otherwise I'll go searching around for it on Monday. |
||
| } | ||
|
|
||
| $WeCanGit = ( (Test-Path $( Join-Path $Path .git )) -and (Get-Command $GitPath -ErrorAction SilentlyContinue) ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,14 +77,14 @@ | |
| } | ||
| $true | ||
| })] | ||
| [string]$GitPath = 'git' | ||
| [string]$GitPath | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The hard coded git.exe we are searching for makes this default value unnecessary. |
||
| ) | ||
|
|
||
| $Path = (Resolve-Path $Path).Path | ||
| # http://stackoverflow.com/questions/8761888/powershell-capturing-standard-out-and-error-with-start-process | ||
| $pinfo = New-Object System.Diagnostics.ProcessStartInfo | ||
| if(!$PSBoundParameters.ContainsKey('GitPath')) { | ||
| $GitPath = (Get-Command $GitPath -ErrorAction Stop)[0].Path | ||
| $GitPath = (Get-ChildItem ($env:PATH -split ';') -filter git.exe -ErrorAction SilentlyContinue | Select-Object -First 1).Fullname | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. |
||
| } | ||
| $pinfo.FileName = $GitPath | ||
| $Command = $GitPath | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hard coded git.exe we are searching for makes this default value unnecessary.