Skip to content

Commit

Permalink
Add version check to install and module. Closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Jan 21, 2011
1 parent 9b41b27 commit 6cea2f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CheckVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$version = git --version 2> $null
if($version -notlike 'git version 1.7.*.msysgit.*') {
Write-Warning "posh-git requires msysgit version 1.7. You have $version."
$false
} else {
$true
}
6 changes: 5 additions & 1 deletion install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ if(!(Get-Command git -ErrorAction SilentlyContinue)) {
return
}

$installDir = Split-Path $MyInvocation.MyCommand.Path -Parent
if(!($installDir\CheckVersion.ps1)) {
return
}

if(!(Test-Path $PROFILE)) {
Write-Host "Creating PowerShell profile...`n$PROFILE"
New-Item $PROFILE -Force -Type File -ErrorAction Stop -WhatIf:$WhatIf > $null
Expand All @@ -31,7 +36,6 @@ function Get-FileEncoding($Path) {
}
}

$installDir = Split-Path $MyInvocation.MyCommand.Path -Parent
$profileLine = ". $installDir\profile.example.ps1"
if(Select-String -Path $PROFILE -Pattern $profileLine -Quiet -SimpleMatch) {
Write-Host "It seems posh-git is already installed..."
Expand Down
2 changes: 2 additions & 0 deletions posh-git.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Push-Location $psScriptRoot
.\CheckVersion.ps1 > $null

. ./Utils.ps1
. ./GitUtils.ps1
. ./GitPrompt.ps1
Expand Down

0 comments on commit 6cea2f4

Please sign in to comment.