Skip to content

Commit

Permalink
Merge pull request #807 from dahlbyk/cygwin-warning
Browse files Browse the repository at this point in the history
Add warning for non-G4W on Windows
  • Loading branch information
dahlbyk authored Oct 31, 2020
2 parents 43e2bf7 + 4be0619 commit 2f46a7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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 '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

0 comments on commit 2f46a7c

Please sign in to comment.