From 297e07a6969930cb686f8852674498395e0af4d3 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Thu, 5 Jan 2017 13:15:20 -0600 Subject: [PATCH 01/26] Remove Chocolatey prompt override --- chocolatey/tools/chocolateyInstall.ps1 | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/chocolatey/tools/chocolateyInstall.ps1 b/chocolatey/tools/chocolateyInstall.ps1 index a72a52a5c..2806a3124 100644 --- a/chocolatey/tools/chocolateyInstall.ps1 +++ b/chocolatey/tools/chocolateyInstall.ps1 @@ -1,8 +1,4 @@ -function Insert-Script([ref]$originalScript, $script) { - if(!($originalScript.Value -Contains $script)) { $originalScript.Value += $script } -} - -try { +try { $binRoot = Get-BinRoot $oldPromptOverride = "if(Test-Path Function:\Prompt) {Rename-Item Function:\Prompt PrePoshGitPrompt -Force}" @@ -16,7 +12,7 @@ try { remove-item $poshgitPath -recurse -force } } catch { - Write-Host 'Could not remove poshgit folder' + Write-Host "Could not remove `'$poshgitPath`'" } $poshGitInstall = if($env:poshGit -ne $null){ $env:poshGit } else {'https://github.com/dahlbyk/posh-git/zipball/master'} @@ -30,26 +26,15 @@ try { $pgitExample = "$pgitDir\profile.example.ps1" foreach($line in $oldProfile) { if($line.ToLower().Contains("$poshgitPath".ToLower())) { - Insert-Script ([REF]$newProfile) $oldPromptOverride $line = ". '$pgitExample'" } if($line.Trim().Length -gt 0) { $newProfile += $line } } - # Save any previous Prompt logic - Insert-Script ([REF]$newProfile) $oldPromptOverride Set-Content -path $profile -value $newProfile -Force } $installer = Join-Path $pgitDir 'install.ps1' & $installer - - $newProfile = @(Get-Content $PROFILE) - Insert-Script ([REF]$newProfile) "Rename-Item Function:\Prompt PoshGitPrompt -Force" - - # function that will run previous prompt logic and then the poshgit logic - # all output from previous prompts will be swallowed - Insert-Script ([REF]$newProfile) $newPromptOverride - Set-Content -path $profile -value $newProfile -Force } catch { try { if($oldProfile){ Set-Content -path $PROFILE -value $oldProfile -Force } From 48f61c9995d6bd122be2a540f1bf8081f495ec41 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Thu, 5 Jan 2017 13:16:28 -0600 Subject: [PATCH 02/26] Strip Chocolatey prompt override on install --- chocolatey/tools/chocolateyInstall.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/chocolatey/tools/chocolateyInstall.ps1 b/chocolatey/tools/chocolateyInstall.ps1 index 2806a3124..145bdd887 100644 --- a/chocolatey/tools/chocolateyInstall.ps1 +++ b/chocolatey/tools/chocolateyInstall.ps1 @@ -1,9 +1,5 @@ try { $binRoot = Get-BinRoot - - $oldPromptOverride = "if(Test-Path Function:\Prompt) {Rename-Item Function:\Prompt PrePoshGitPrompt -Force}" - $newPromptOverride = "function Prompt() {if(Test-Path Function:\PrePoshGitPrompt){++`$global:poshScope; New-Item function:\script:Write-host -value `"param([object] ```$object, ```$backgroundColor, ```$foregroundColor, [switch] ```$nonewline) `" -Force | Out-Null;`$private:p = PrePoshGitPrompt; if(--`$global:poshScope -eq 0) {Remove-Item function:\Write-Host -Force}}PoshGitPrompt}" - $poshgitPath = join-path $binRoot 'poshgit' try { @@ -25,6 +21,8 @@ #If old profile exists replace with new one and make sure prompt preservation function is on top $pgitExample = "$pgitDir\profile.example.ps1" foreach($line in $oldProfile) { + if ($line -like '*PoshGitPrompt*') { continue; } + if($line.ToLower().Contains("$poshgitPath".ToLower())) { $line = ". '$pgitExample'" } From 35c57a9e04226b442fcdf27bd15d10f5aaa87c09 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Fri, 27 Jan 2017 12:02:56 -0600 Subject: [PATCH 03/26] Trivial cleanup --- chocolatey/tools/chocolateyInstall.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chocolatey/tools/chocolateyInstall.ps1 b/chocolatey/tools/chocolateyInstall.ps1 index 145bdd887..861a32878 100644 --- a/chocolatey/tools/chocolateyInstall.ps1 +++ b/chocolatey/tools/chocolateyInstall.ps1 @@ -4,14 +4,14 @@ try { if (test-path($poshgitPath)) { - Write-Host "Attempting to remove existing `'$poshgitPath`' prior to install." + Write-Host "Attempting to remove existing `'$poshgitPath`'." remove-item $poshgitPath -recurse -force } } catch { Write-Host "Could not remove `'$poshgitPath`'" } - $poshGitInstall = if($env:poshGit -ne $null){ $env:poshGit } else {'https://github.com/dahlbyk/posh-git/zipball/master'} + $poshGitInstall = if ($env:poshGit ) { $env:poshGit } else { 'https://github.com/dahlbyk/posh-git/zipball/master' } Install-ChocolateyZipPackage 'poshgit' $poshGitInstall $poshgitPath $pgitDir = Dir "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime | Select -Last 1 @@ -26,7 +26,7 @@ if($line.ToLower().Contains("$poshgitPath".ToLower())) { $line = ". '$pgitExample'" } - if($line.Trim().Length -gt 0) { $newProfile += $line } + $newProfile += $line } Set-Content -path $profile -value $newProfile -Force } From c1c9748923bb3f5935ba3a0d971e841d49f1d5b5 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Fri, 27 Jan 2017 12:03:54 -0600 Subject: [PATCH 04/26] Refactor/simplify check for existing profile import --- chocolatey/tools/chocolateyInstall.ps1 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/chocolatey/tools/chocolateyInstall.ps1 b/chocolatey/tools/chocolateyInstall.ps1 index 861a32878..20969d2a0 100644 --- a/chocolatey/tools/chocolateyInstall.ps1 +++ b/chocolatey/tools/chocolateyInstall.ps1 @@ -13,25 +13,23 @@ $poshGitInstall = if ($env:poshGit ) { $env:poshGit } else { 'https://github.com/dahlbyk/posh-git/zipball/master' } Install-ChocolateyZipPackage 'poshgit' $poshGitInstall $poshgitPath - $pgitDir = Dir "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime | Select -Last 1 + $currentVersionPath = Get-ChildItem "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime | Select-Object -Last 1 if(Test-Path $PROFILE) { $oldProfile = @(Get-Content $PROFILE) $newProfile = @() - #If old profile exists replace with new one and make sure prompt preservation function is on top - $pgitExample = "$pgitDir\profile.example.ps1" foreach($line in $oldProfile) { if ($line -like '*PoshGitPrompt*') { continue; } - if($line.ToLower().Contains("$poshgitPath".ToLower())) { - $line = ". '$pgitExample'" + if($line -like '. *posh-git*profile.example.ps1*') { + $line = ". '$currentVersionPath\profile.example.ps1'" } $newProfile += $line } Set-Content -path $profile -value $newProfile -Force } - $installer = Join-Path $pgitDir 'install.ps1' + $installer = Join-Path $currentVersionPath 'install.ps1' & $installer } catch { try { From 8248f0394881d443f79335861aac9ffad1c2dc5a Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 12:01:29 -0600 Subject: [PATCH 05/26] Update Chocolatey to fix Import-Module path, too Old install dot-sourced profile.example.ps1 New install adds Import-Module --- chocolatey/tools/chocolateyInstall.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chocolatey/tools/chocolateyInstall.ps1 b/chocolatey/tools/chocolateyInstall.ps1 index 20969d2a0..03f6ea6c9 100644 --- a/chocolatey/tools/chocolateyInstall.ps1 +++ b/chocolatey/tools/chocolateyInstall.ps1 @@ -24,6 +24,9 @@ if($line -like '. *posh-git*profile.example.ps1*') { $line = ". '$currentVersionPath\profile.example.ps1'" } + if($line -like 'Import-Module *\src\posh-git.psd1*') { + $line = "Import-Module '$currentVersionPath\src\posh-git.psd1'" + } $newProfile += $line } Set-Content -path $profile -value $newProfile -Force From e1d10acd7cb2c786c88095066816f3c9288da7e9 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Fri, 27 Jan 2017 12:15:13 -0600 Subject: [PATCH 06/26] Preserve $PROFILE encoding on Chocolatey install --- chocolatey/tools/chocolateyInstall.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chocolatey/tools/chocolateyInstall.ps1 b/chocolatey/tools/chocolateyInstall.ps1 index 03f6ea6c9..73ade3d43 100644 --- a/chocolatey/tools/chocolateyInstall.ps1 +++ b/chocolatey/tools/chocolateyInstall.ps1 @@ -17,6 +17,10 @@ if(Test-Path $PROFILE) { $oldProfile = @(Get-Content $PROFILE) + + . $currentVersionPath\src\Utils.ps1 + $oldProfileEncoding = Get-FileEncoding $PROFILE + $newProfile = @() foreach($line in $oldProfile) { if ($line -like '*PoshGitPrompt*') { continue; } @@ -29,14 +33,14 @@ } $newProfile += $line } - Set-Content -path $profile -value $newProfile -Force + Set-Content -path $profile -value $newProfile -Force -Encoding $oldProfileEncoding } $installer = Join-Path $currentVersionPath 'install.ps1' & $installer } catch { try { - if($oldProfile){ Set-Content -path $PROFILE -value $oldProfile -Force } + if($oldProfile){ Set-Content -path $PROFILE -value $oldProfile -Force -Encoding $oldProfileEncoding } } catch {} throw From 6abca6a1c898d6754405371b0b29307c957b2801 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Thu, 5 Jan 2017 13:22:08 -0600 Subject: [PATCH 07/26] Clone Chocolatey install as uninstall --- chocolatey/tools/chocolateyUninstall.ps1 | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 chocolatey/tools/chocolateyUninstall.ps1 diff --git a/chocolatey/tools/chocolateyUninstall.ps1 b/chocolatey/tools/chocolateyUninstall.ps1 new file mode 100644 index 000000000..73ade3d43 --- /dev/null +++ b/chocolatey/tools/chocolateyUninstall.ps1 @@ -0,0 +1,48 @@ +try { + $binRoot = Get-BinRoot + $poshgitPath = join-path $binRoot 'poshgit' + + try { + if (test-path($poshgitPath)) { + Write-Host "Attempting to remove existing `'$poshgitPath`'." + remove-item $poshgitPath -recurse -force + } + } catch { + Write-Host "Could not remove `'$poshgitPath`'" + } + + $poshGitInstall = if ($env:poshGit ) { $env:poshGit } else { 'https://github.com/dahlbyk/posh-git/zipball/master' } + Install-ChocolateyZipPackage 'poshgit' $poshGitInstall $poshgitPath + $currentVersionPath = Get-ChildItem "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime | Select-Object -Last 1 + + if(Test-Path $PROFILE) { + $oldProfile = @(Get-Content $PROFILE) + + . $currentVersionPath\src\Utils.ps1 + $oldProfileEncoding = Get-FileEncoding $PROFILE + + $newProfile = @() + foreach($line in $oldProfile) { + if ($line -like '*PoshGitPrompt*') { continue; } + + if($line -like '. *posh-git*profile.example.ps1*') { + $line = ". '$currentVersionPath\profile.example.ps1'" + } + if($line -like 'Import-Module *\src\posh-git.psd1*') { + $line = "Import-Module '$currentVersionPath\src\posh-git.psd1'" + } + $newProfile += $line + } + Set-Content -path $profile -value $newProfile -Force -Encoding $oldProfileEncoding + } + + $installer = Join-Path $currentVersionPath 'install.ps1' + & $installer +} catch { + try { + if($oldProfile){ Set-Content -path $PROFILE -value $oldProfile -Force -Encoding $oldProfileEncoding } + } + catch {} + throw +} + From 962d38b867a4c5999c046399c9cd2aac63177732 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Thu, 5 Jan 2017 13:22:08 -0600 Subject: [PATCH 08/26] Add Chocolatey uninstall --- chocolatey/tools/chocolateyUninstall.ps1 | 26 ++++++++++-------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/chocolatey/tools/chocolateyUninstall.ps1 b/chocolatey/tools/chocolateyUninstall.ps1 index 73ade3d43..311fb9878 100644 --- a/chocolatey/tools/chocolateyUninstall.ps1 +++ b/chocolatey/tools/chocolateyUninstall.ps1 @@ -2,17 +2,6 @@ $binRoot = Get-BinRoot $poshgitPath = join-path $binRoot 'poshgit' - try { - if (test-path($poshgitPath)) { - Write-Host "Attempting to remove existing `'$poshgitPath`'." - remove-item $poshgitPath -recurse -force - } - } catch { - Write-Host "Could not remove `'$poshgitPath`'" - } - - $poshGitInstall = if ($env:poshGit ) { $env:poshGit } else { 'https://github.com/dahlbyk/posh-git/zipball/master' } - Install-ChocolateyZipPackage 'poshgit' $poshGitInstall $poshgitPath $currentVersionPath = Get-ChildItem "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime | Select-Object -Last 1 if(Test-Path $PROFILE) { @@ -24,20 +13,27 @@ $newProfile = @() foreach($line in $oldProfile) { if ($line -like '*PoshGitPrompt*') { continue; } + if ($line -like '*Load posh-git example profile*') { continue; } if($line -like '. *posh-git*profile.example.ps1*') { - $line = ". '$currentVersionPath\profile.example.ps1'" + continue; } if($line -like 'Import-Module *\src\posh-git.psd1*') { - $line = "Import-Module '$currentVersionPath\src\posh-git.psd1'" + continue; } $newProfile += $line } Set-Content -path $profile -value $newProfile -Force -Encoding $oldProfileEncoding } - $installer = Join-Path $currentVersionPath 'install.ps1' - & $installer + try { + if (test-path($poshgitPath)) { + Write-Host "Attempting to remove existing `'$poshgitPath`'." + remove-item $poshgitPath -recurse -force + } + } catch { + Write-Host "Could not remove `'$poshgitPath`'" + } } catch { try { if($oldProfile){ Set-Content -path $PROFILE -value $oldProfile -Force -Encoding $oldProfileEncoding } From 1c77805ebf4f7942adb27b6dba1e6528dfe55e70 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Sun, 29 Jan 2017 21:42:45 -0600 Subject: [PATCH 09/26] Pin Choclatey install to version tag --- chocolatey/tools/chocolateyInstall.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chocolatey/tools/chocolateyInstall.ps1 b/chocolatey/tools/chocolateyInstall.ps1 index 73ade3d43..20674dbe2 100644 --- a/chocolatey/tools/chocolateyInstall.ps1 +++ b/chocolatey/tools/chocolateyInstall.ps1 @@ -11,7 +11,9 @@ Write-Host "Could not remove `'$poshgitPath`'" } - $poshGitInstall = if ($env:poshGit ) { $env:poshGit } else { 'https://github.com/dahlbyk/posh-git/zipball/master' } + $version = "v$Env:chocolateyPackageVersion" + if ($version -eq 'v') { $version = 'master' } + $poshGitInstall = if ($env:poshGit ) { $env:poshGit } else { "https://github.com/dahlbyk/posh-git/zipball/$version" } Install-ChocolateyZipPackage 'poshgit' $poshGitInstall $poshgitPath $currentVersionPath = Get-ChildItem "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime | Select-Object -Last 1 From 7e420384451ba6657f112cf5fa80b47a2e014b56 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Sun, 29 Jan 2017 21:47:34 -0600 Subject: [PATCH 10/26] Update Chocolatey to 0.7.0-pre1 --- chocolatey/poshgit.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/poshgit.nuspec b/chocolatey/poshgit.nuspec index 661b5ff6c..6ab6956fc 100644 --- a/chocolatey/poshgit.nuspec +++ b/chocolatey/poshgit.nuspec @@ -3,7 +3,7 @@ poshgit posh-git - 0.6.1.20160330 + 0.7.0-pre1 Keith Dahlby, Mark Embling, Jeremy Skinner Keith Dahlby ### posh-git From 7fd96386e1e5c7bc4f7db36fa928ad8cb2a34000 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Sun, 29 Jan 2017 22:04:55 -0600 Subject: [PATCH 11/26] Suppress Chocolatey installation location --- chocolatey/tools/chocolateyInstall.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/tools/chocolateyInstall.ps1 b/chocolatey/tools/chocolateyInstall.ps1 index 20674dbe2..0f6caf308 100644 --- a/chocolatey/tools/chocolateyInstall.ps1 +++ b/chocolatey/tools/chocolateyInstall.ps1 @@ -14,7 +14,7 @@ $version = "v$Env:chocolateyPackageVersion" if ($version -eq 'v') { $version = 'master' } $poshGitInstall = if ($env:poshGit ) { $env:poshGit } else { "https://github.com/dahlbyk/posh-git/zipball/$version" } - Install-ChocolateyZipPackage 'poshgit' $poshGitInstall $poshgitPath + $zip = Install-ChocolateyZipPackage 'poshgit' $poshGitInstall $poshgitPath $currentVersionPath = Get-ChildItem "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime | Select-Object -Last 1 if(Test-Path $PROFILE) { From 9f6b256f32cade8c08251e2bc7b9159b90e00376 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Sun, 29 Jan 2017 22:10:48 -0600 Subject: [PATCH 12/26] Add script to streamline local pack/install loop --- chocolatey/packAndLocalInstall.ps1 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 chocolatey/packAndLocalInstall.ps1 diff --git a/chocolatey/packAndLocalInstall.ps1 b/chocolatey/packAndLocalInstall.ps1 new file mode 100644 index 000000000..4afd735d5 --- /dev/null +++ b/chocolatey/packAndLocalInstall.ps1 @@ -0,0 +1,4 @@ +pushd $PSScriptRoot +choco pack poshgit.nuspec +choco install -f -y poshgit -pre -s . +popd From 9d559c4ea99ec4d54b60981a90d21a71c1d52a40 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 14:14:32 -0600 Subject: [PATCH 13/26] Bump to 0.7.0-pre2 --- chocolatey/poshgit.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/poshgit.nuspec b/chocolatey/poshgit.nuspec index 6ab6956fc..b459651eb 100644 --- a/chocolatey/poshgit.nuspec +++ b/chocolatey/poshgit.nuspec @@ -3,7 +3,7 @@ poshgit posh-git - 0.7.0-pre1 + 0.7.0-pre2 Keith Dahlby, Mark Embling, Jeremy Skinner Keith Dahlby ### posh-git From 375519143eb535ae5c4182b15493ff8fe6605954 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 17:01:20 -0600 Subject: [PATCH 14/26] Warn/quit if $profilePath is missing --- src/Utils.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Utils.ps1 b/src/Utils.ps1 index 2e0167571..ea723eb07 100644 --- a/src/Utils.ps1 +++ b/src/Utils.ps1 @@ -118,6 +118,11 @@ function Add-PoshGitToProfile([switch]$AllHosts, [switch]$Force, [switch]$WhatIf } } + if (!$profilePath) { + Write-Warning "Skipping add of posh-git import; no profile found." + return + } + # Check if the location of this module file is in the PSModulePath if (Test-InPSModulePath $ModuleBasePath) { $profileContent = "`nImport-Module posh-git" From 5f8c8994f29b72c9878ff3bca9bc7aa136fc5461 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 17:02:23 -0600 Subject: [PATCH 15/26] Add verbose logging around Add-PoshGitToProfile --- src/Utils.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Utils.ps1 b/src/Utils.ps1 index ea723eb07..8416c0ae6 100644 --- a/src/Utils.ps1 +++ b/src/Utils.ps1 @@ -120,6 +120,11 @@ function Add-PoshGitToProfile([switch]$AllHosts, [switch]$Force, [switch]$WhatIf if (!$profilePath) { Write-Warning "Skipping add of posh-git import; no profile found." + Write-Verbose "`$profilePath = '$profilePath'" + Write-Verbose "CurrentUserCurrentHost = '${PROFILE.CurrentUserCurrentHost}'" + Write-Verbose "CurrentUserAllHosts = '${PROFILE.CurrentUserAllHosts}'" + Write-Verbose "AllUsersCurrentHost = '${PROFILE.AllUsersCurrentHost}'" + Write-Verbose "AllUsersAllHosts = '${PROFILE.AllUsersAllHosts}'" return } @@ -220,7 +225,9 @@ function Test-PoshGitImportedInScript { return $false } - (@(Get-Content $Path -ErrorAction SilentlyContinue) -match 'posh-git').Count -gt 0 + $match = (@(Get-Content $Path -ErrorAction SilentlyContinue) -match 'posh-git').Count -gt 0 + if ($match) { Write-Verbose "posh-git found in '$Path'" } + $match } function dbg($Message, [Diagnostics.Stopwatch]$Stopwatch) { From a4edddd34159ab5ccc6ac022149303d3663e86f6 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 17:04:00 -0600 Subject: [PATCH 16/26] Bump to 0.7.0-pre3 --- chocolatey/poshgit.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/poshgit.nuspec b/chocolatey/poshgit.nuspec index b459651eb..2605d6b3c 100644 --- a/chocolatey/poshgit.nuspec +++ b/chocolatey/poshgit.nuspec @@ -3,7 +3,7 @@ poshgit posh-git - 0.7.0-pre2 + 0.7.0-pre3 Keith Dahlby, Mark Embling, Jeremy Skinner Keith Dahlby ### posh-git From 6bdac52ff035ac9c5c0bc6bf577d6d639bee6b94 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 17:20:53 -0600 Subject: [PATCH 17/26] Add $PROFILE to verbose output --- src/Utils.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Utils.ps1 b/src/Utils.ps1 index 8416c0ae6..6c730bfa8 100644 --- a/src/Utils.ps1 +++ b/src/Utils.ps1 @@ -121,6 +121,7 @@ function Add-PoshGitToProfile([switch]$AllHosts, [switch]$Force, [switch]$WhatIf if (!$profilePath) { Write-Warning "Skipping add of posh-git import; no profile found." Write-Verbose "`$profilePath = '$profilePath'" + Write-Verbose "`$PROFILE = '$PROFILE'" Write-Verbose "CurrentUserCurrentHost = '${PROFILE.CurrentUserCurrentHost}'" Write-Verbose "CurrentUserAllHosts = '${PROFILE.CurrentUserAllHosts}'" Write-Verbose "AllUsersCurrentHost = '${PROFILE.AllUsersCurrentHost}'" From 77aaa9c6d42f87229d78f8cf359182690f6a9a09 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 19:29:43 -0600 Subject: [PATCH 18/26] Fix poorly formed interpolation --- src/Utils.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Utils.ps1 b/src/Utils.ps1 index 6c730bfa8..0e72c64a3 100644 --- a/src/Utils.ps1 +++ b/src/Utils.ps1 @@ -122,10 +122,10 @@ function Add-PoshGitToProfile([switch]$AllHosts, [switch]$Force, [switch]$WhatIf Write-Warning "Skipping add of posh-git import; no profile found." Write-Verbose "`$profilePath = '$profilePath'" Write-Verbose "`$PROFILE = '$PROFILE'" - Write-Verbose "CurrentUserCurrentHost = '${PROFILE.CurrentUserCurrentHost}'" - Write-Verbose "CurrentUserAllHosts = '${PROFILE.CurrentUserAllHosts}'" - Write-Verbose "AllUsersCurrentHost = '${PROFILE.AllUsersCurrentHost}'" - Write-Verbose "AllUsersAllHosts = '${PROFILE.AllUsersAllHosts}'" + Write-Verbose "CurrentUserCurrentHost = '$($PROFILE.CurrentUserCurrentHost)'" + Write-Verbose "CurrentUserAllHosts = '$($PROFILE.CurrentUserAllHosts)'" + Write-Verbose "AllUsersCurrentHost = '$($PROFILE.AllUsersCurrentHost)'" + Write-Verbose "AllUsersAllHosts = '$($PROFILE.AllUsersAllHosts)'" return } From 5c8e0480cee231c3d4da148ca35c61788ce11d19 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 19:31:59 -0600 Subject: [PATCH 19/26] Bump to 0.7.0-pre4 --- chocolatey/poshgit.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/poshgit.nuspec b/chocolatey/poshgit.nuspec index 2605d6b3c..c213a275f 100644 --- a/chocolatey/poshgit.nuspec +++ b/chocolatey/poshgit.nuspec @@ -3,7 +3,7 @@ poshgit posh-git - 0.7.0-pre3 + 0.7.0-pre4 Keith Dahlby, Mark Embling, Jeremy Skinner Keith Dahlby ### posh-git From 9a1d91db0b33180266daf5af1c7cacf42fe04a82 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 19:38:22 -0600 Subject: [PATCH 20/26] Specify local version to install --- chocolatey/packAndLocalInstall.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chocolatey/packAndLocalInstall.ps1 b/chocolatey/packAndLocalInstall.ps1 index 4afd735d5..90ee8262f 100644 --- a/chocolatey/packAndLocalInstall.ps1 +++ b/chocolatey/packAndLocalInstall.ps1 @@ -1,4 +1,9 @@ pushd $PSScriptRoot + +$nuspec = [xml](Get-Content poshgit.nuspec) +$version = $nuspec.package.metadata.version + choco pack poshgit.nuspec -choco install -f -y poshgit -pre -s . +choco install -f -y poshgit -pre --version=$version -s . + popd From 8161c8f02edb0d8aafe0c85f638dad7b435767f0 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 19:53:53 -0600 Subject: [PATCH 21/26] Fail if the version tag doesn't exist --- chocolatey/packAndLocalInstall.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chocolatey/packAndLocalInstall.ps1 b/chocolatey/packAndLocalInstall.ps1 index 90ee8262f..859069f7d 100644 --- a/chocolatey/packAndLocalInstall.ps1 +++ b/chocolatey/packAndLocalInstall.ps1 @@ -3,6 +3,9 @@ pushd $PSScriptRoot $nuspec = [xml](Get-Content poshgit.nuspec) $version = $nuspec.package.metadata.version +$ErrorActionPreference = 'Stop' +git rev-parse "v$version" 2>$null + choco pack poshgit.nuspec choco install -f -y poshgit -pre --version=$version -s . From c9c1b52fc2203851261c60f2b99c656fe8fae951 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 20:29:02 -0600 Subject: [PATCH 22/26] Confirm remote tag, with -Force option to create --- chocolatey/packAndLocalInstall.ps1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/chocolatey/packAndLocalInstall.ps1 b/chocolatey/packAndLocalInstall.ps1 index 859069f7d..2472fc91e 100644 --- a/chocolatey/packAndLocalInstall.ps1 +++ b/chocolatey/packAndLocalInstall.ps1 @@ -1,10 +1,20 @@ +param ($Remote = 'origin', [switch]$Force) pushd $PSScriptRoot $nuspec = [xml](Get-Content poshgit.nuspec) $version = $nuspec.package.metadata.version $ErrorActionPreference = 'Stop' -git rev-parse "v$version" 2>$null +$remoteRef = $(git ls-remote $Remote "v$version") +if (!$remoteRef) { + if ($Force) { + git push -f $Remote "HEAD:refs/tags/v$version" + } + else { + Write-Warning "'$Remote/v$version' not found! Use -Force to create tag at HEAD." + return + } +} choco pack poshgit.nuspec choco install -f -y poshgit -pre --version=$version -s . From 4c8cbc6734bd5645cebb136b32a569df009ca20e Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 20:34:15 -0600 Subject: [PATCH 23/26] Add handling for non-standard $PROFILE --- src/Utils.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Utils.ps1 b/src/Utils.ps1 index 0e72c64a3..69a778c98 100644 --- a/src/Utils.ps1 +++ b/src/Utils.ps1 @@ -93,10 +93,15 @@ function Add-PoshGitToProfile([switch]$AllHosts, [switch]$Force, [switch]$WhatIf } } + if (!$profilePath) { $profilePath = $PROFILE } + if (!$Force) { # Search the user's profiles to see if any are using posh-git already, there is an extra search # ($profilePath) taking place to accomodate the Pester tests. $importedInProfile = Test-PoshGitImportedInScript $profilePath + if (!$importedInProfile -and !$underTest) { + $importedInProfile = Test-PoshGitImportedInScript $PROFILE + } if (!$importedInProfile -and !$underTest) { $importedInProfile = Test-PoshGitImportedInScript $PROFILE.CurrentUserCurrentHost } From 7620aaf9e6decf58ff8eb37a89bca2696996e37c Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 20:38:46 -0600 Subject: [PATCH 24/26] Force should always update remote tag --- chocolatey/packAndLocalInstall.ps1 | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/chocolatey/packAndLocalInstall.ps1 b/chocolatey/packAndLocalInstall.ps1 index 2472fc91e..9640b87a5 100644 --- a/chocolatey/packAndLocalInstall.ps1 +++ b/chocolatey/packAndLocalInstall.ps1 @@ -4,16 +4,13 @@ pushd $PSScriptRoot $nuspec = [xml](Get-Content poshgit.nuspec) $version = $nuspec.package.metadata.version -$ErrorActionPreference = 'Stop' -$remoteRef = $(git ls-remote $Remote "v$version") -if (!$remoteRef) { - if ($Force) { - git push -f $Remote "HEAD:refs/tags/v$version" - } - else { - Write-Warning "'$Remote/v$version' not found! Use -Force to create tag at HEAD." - return - } + +if ($Force) { + git push -f $Remote "HEAD:refs/tags/v$version" +} +elseif (!$(git ls-remote $Remote "v$version")) { + Write-Warning "'$Remote/v$version' not found! Use -Force to create tag at HEAD." + return } choco pack poshgit.nuspec From 04c24157b1e181a262d8b8fa6b678ab0b4c0be30 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Mon, 30 Jan 2017 20:45:50 -0600 Subject: [PATCH 25/26] Create local tag, too --- chocolatey/packAndLocalInstall.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/chocolatey/packAndLocalInstall.ps1 b/chocolatey/packAndLocalInstall.ps1 index 9640b87a5..9c2a9a6b4 100644 --- a/chocolatey/packAndLocalInstall.ps1 +++ b/chocolatey/packAndLocalInstall.ps1 @@ -3,13 +3,14 @@ pushd $PSScriptRoot $nuspec = [xml](Get-Content poshgit.nuspec) $version = $nuspec.package.metadata.version - +$tag = "v$version" if ($Force) { - git push -f $Remote "HEAD:refs/tags/v$version" + git tag -f $tag + git push -f $Remote $tag } -elseif (!$(git ls-remote $Remote "v$version")) { - Write-Warning "'$Remote/v$version' not found! Use -Force to create tag at HEAD." +elseif (!$(git ls-remote $Remote $tag)) { + Write-Warning "'$Remote/$tag' not found! Use -Force to create tag at HEAD." return } From 8a4207d8303e039b02394b3b99ad328f73b174a7 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Fri, 3 Feb 2017 08:58:28 -0600 Subject: [PATCH 26/26] Bump to 0.7.0-pre5 --- chocolatey/poshgit.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/poshgit.nuspec b/chocolatey/poshgit.nuspec index c213a275f..5e137a72f 100644 --- a/chocolatey/poshgit.nuspec +++ b/chocolatey/poshgit.nuspec @@ -3,7 +3,7 @@ poshgit posh-git - 0.7.0-pre4 + 0.7.0-pre5 Keith Dahlby, Mark Embling, Jeremy Skinner Keith Dahlby ### posh-git