Skip to content
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

Add warning for non-G4W on Windows #807

Merged
merged 2 commits into from
Oct 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/CheckRequirements.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ $global:GitMissing = $false

$requiredVersion = [Version]'1.7.2'
$script:GitVersion = $requiredVersion
$script:GitCygwin = $false

if (!(Get-Command git -TotalCount 1 -ErrorAction SilentlyContinue)) {
Write-Warning "git command could not be found. Please create an alias or add it to your PATH."
$Global:GitMissing = $true
return
}

if ([string](git --version 2> $null) -match '(?<ver>\d+(?:\.\d+)+)') {
if ([string](git --version 2> $null) -match '(?<ver>\d+(?:\.\d+)+)(?<g4w>\.windows)?') {
$script:GitVersion = [System.Version]$Matches['ver']

if (($PSVersionTable.PSVersion.Major -le 5) -or $IsWindows) {
if (!$Matches['g4w']) {
$script:GitCygwin = $true

if (!$Env:POSHGIT_CYGWIN_WARNING) {
Write-Warning "posh-git recommends Git for Windows. You appear to have a different distribution."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we mention why we recommend Git for Windows? Maybe ... recommends Git for Windows for proper ANSI/VT support. .... or something like that.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You appear to have an unsupported Git distribution; setting $GitPromptSettings.AnsiConsole = $false. posh-git recommends Git for Windows.

}
}
}
}

if ($GitVersion -lt $requiredVersion) {
Expand Down
2 changes: 1 addition & 1 deletion src/PoshGitTypes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class PoshGitTextSpan {
}

class PoshGitPromptSettings {
[bool]$AnsiConsole = $Host.UI.SupportsVirtualTerminal -or ($Env:ConEmuANSI -eq "ON")
[bool]$AnsiConsole = ($Host.UI.SupportsVirtualTerminal -or ($Env:ConEmuANSI -eq "ON")) -and !$script:GitCygwin
[bool]$SetEnvColumns = $true

[PoshGitCellColor]$DefaultColor = [PoshGitCellColor]::new()
Expand Down