From a91bfd789dc513d6a4c4488470270ba0e189c027 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 10 Jul 2017 17:08:14 -0600 Subject: [PATCH 1/8] Specify CommandType as Application Related #478. This is a better fix. By specifying the CommandType as Application we can continue looking for `git` (exe or cmd) but avoiding any potential aliases the user may have created for "git". --- src/GitUtils.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitUtils.ps1 b/src/GitUtils.ps1 index 0c221c41c..e1e7ef14b 100644 --- a/src/GitUtils.ps1 +++ b/src/GitUtils.ps1 @@ -434,7 +434,7 @@ function Find-Pageant() { # Attempt to guess $program's location. For ssh-agent/ssh-add. function Find-Ssh($program = 'ssh-agent') { Write-Verbose "$program not in path. Trying to guess location." - $gitItem = Get-Command git -Erroraction SilentlyContinue | Get-Item + $gitItem = Get-Command git -CommandType Application -Erroraction SilentlyContinue | Get-Item if ($null -eq $gitItem) { Write-Warning 'git not in path' return From 72c874754e5263acb952b31a3b6f8c4ddafc840b Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Mon, 1 Jan 2018 14:04:03 -0700 Subject: [PATCH 2/8] Export $GitPromptScriptBlock variable Allow advanced users to invoke the $scriptblock from their own prompt functions. --- src/posh-git.psd1 | 2 +- src/posh-git.psm1 | 139 +++++++++++++++++++++++----------------------- 2 files changed, 71 insertions(+), 70 deletions(-) diff --git a/src/posh-git.psd1 b/src/posh-git.psd1 index a5267aadb..775f11b84 100644 --- a/src/posh-git.psd1 +++ b/src/posh-git.psd1 @@ -47,7 +47,7 @@ FunctionsToExport = @( CmdletsToExport = @() # Variables to export from this module -VariablesToExport = @() +VariablesToExport = @('GitPromptScriptBlock') # Aliases to export from this module AliasesToExport = @('??') diff --git a/src/posh-git.psm1 b/src/posh-git.psm1 index a056318f1..fb141dfc4 100644 --- a/src/posh-git.psm1 +++ b/src/posh-git.psm1 @@ -34,8 +34,70 @@ else { $defaultPromptDef = [Runspace]::DefaultRunspace.InitialSessionState.Commands['prompt'].Definition } -# If there is no prompt function or the prompt function is the default, replace the current prompt function definition -$poshGitPromptScriptBlock = $null +# The built-in posh-git prompt function in ScriptBlock form. +$GitPromptScriptBlock = { + if ($GitPromptSettings.DefaultPromptEnableTiming) { + $sw = [System.Diagnostics.Stopwatch]::StartNew() + } + $origLastExitCode = $global:LASTEXITCODE + + # A UNC path has no drive so it's better to use the ProviderPath e.g. "\\server\share". + # However for any path with a drive defined, it's better to use the Path property. + # In this case, ProviderPath is "\LocalMachine\My"" whereas Path is "Cert:\LocalMachine\My". + # The latter is more desirable. + $pathInfo = $ExecutionContext.SessionState.Path.CurrentLocation + $currentPath = if ($pathInfo.Drive) { $pathInfo.Path } else { $pathInfo.ProviderPath } + + # File system paths are case-sensitive on Linux and case-insensitive on Windows and macOS + if (($PSVersionTable.PSVersion.Major -ge 6) -and $IsLinux) { + $stringComparison = [System.StringComparison]::Ordinal + } + else { + $stringComparison = [System.StringComparison]::OrdinalIgnoreCase + } + + # Abbreviate path by replacing beginning of path with ~ *iff* the path is in the user's home dir + $abbrevHomeDir = $GitPromptSettings.DefaultPromptAbbreviateHomeDirectory + if ($abbrevHomeDir -and $currentPath -and $currentPath.StartsWith($Home, $stringComparison)) + { + $currentPath = "~" + $currentPath.SubString($Home.Length) + } + + # Display default prompt prefix if not empty. + $defaultPromptPrefix = [string]$GitPromptSettings.DefaultPromptPrefix + if ($defaultPromptPrefix) { + $expandedDefaultPromptPrefix = $ExecutionContext.SessionState.InvokeCommand.ExpandString($defaultPromptPrefix) + Write-Prompt $expandedDefaultPromptPrefix + } + + # Write the abbreviated current path + Write-Prompt $currentPath + + # Write the Git status summary information + Write-VcsStatus + + # If stopped in the debugger, the prompt needs to indicate that in some fashion + $hasInBreakpoint = [runspace]::DefaultRunspace.Debugger | Get-Member -Name InBreakpoint -MemberType property + $debugMode = (Test-Path Variable:/PSDebugContext) -or ($hasInBreakpoint -and [runspace]::DefaultRunspace.Debugger.InBreakpoint) + $promptSuffix = if ($debugMode) { $GitPromptSettings.DefaultPromptDebugSuffix } else { $GitPromptSettings.DefaultPromptSuffix } + + # If user specifies $null or empty string, set to ' ' to avoid "PS>" unexpectedly being displayed + if (!$promptSuffix) { + $promptSuffix = ' ' + } + + $expandedPromptSuffix = $ExecutionContext.SessionState.InvokeCommand.ExpandString($promptSuffix) + + # If prompt timing enabled, display elapsed milliseconds + if ($GitPromptSettings.DefaultPromptEnableTiming) { + $sw.Stop() + $elapsed = $sw.ElapsedMilliseconds + Write-Prompt " ${elapsed}ms" + } + + $global:LASTEXITCODE = $origLastExitCode + $expandedPromptSuffix +} $currentPromptDef = if ($funcInfo = Get-Command prompt -ErrorAction SilentlyContinue) { $funcInfo.Definition } @@ -51,74 +113,10 @@ if (!$currentPromptDef) { function global:prompt { ' ' } } +# If there is no prompt function or the prompt function is the default, replace the current prompt function definition if ($ForcePoshGitPrompt -or !$currentPromptDef -or ($currentPromptDef -eq $defaultPromptDef)) { - # Have to use [scriptblock]::Create() to get debugger detection to work in PS v2 - $poshGitPromptScriptBlock = [scriptblock]::Create(@' - if ($GitPromptSettings.DefaultPromptEnableTiming) { - $sw = [System.Diagnostics.Stopwatch]::StartNew() - } - $origLastExitCode = $global:LASTEXITCODE - - # A UNC path has no drive so it's better to use the ProviderPath e.g. "\\server\share". - # However for any path with a drive defined, it's better to use the Path property. - # In this case, ProviderPath is "\LocalMachine\My"" whereas Path is "Cert:\LocalMachine\My". - # The latter is more desirable. - $pathInfo = $ExecutionContext.SessionState.Path.CurrentLocation - $currentPath = if ($pathInfo.Drive) { $pathInfo.Path } else { $pathInfo.ProviderPath } - - # File system paths are case-sensitive on Linux and case-insensitive on Windows and macOS - if (($PSVersionTable.PSVersion.Major -ge 6) -and $IsLinux) { - $stringComparison = [System.StringComparison]::Ordinal - } - else { - $stringComparison = [System.StringComparison]::OrdinalIgnoreCase - } - - # Abbreviate path by replacing beginning of path with ~ *iff* the path is in the user's home dir - $abbrevHomeDir = $GitPromptSettings.DefaultPromptAbbreviateHomeDirectory - if ($abbrevHomeDir -and $currentPath -and $currentPath.StartsWith($Home, $stringComparison)) - { - $currentPath = "~" + $currentPath.SubString($Home.Length) - } - - # Display default prompt prefix if not empty. - $defaultPromptPrefix = [string]$GitPromptSettings.DefaultPromptPrefix - if ($defaultPromptPrefix) { - $expandedDefaultPromptPrefix = $ExecutionContext.SessionState.InvokeCommand.ExpandString($defaultPromptPrefix) - Write-Prompt $expandedDefaultPromptPrefix - } - - # Write the abbreviated current path - Write-Prompt $currentPath - - # Write the Git status summary information - Write-VcsStatus - - # If stopped in the debugger, the prompt needs to indicate that in some fashion - $hasInBreakpoint = [runspace]::DefaultRunspace.Debugger | Get-Member -Name InBreakpoint -MemberType property - $debugMode = (Test-Path Variable:/PSDebugContext) -or ($hasInBreakpoint -and [runspace]::DefaultRunspace.Debugger.InBreakpoint) - $promptSuffix = if ($debugMode) { $GitPromptSettings.DefaultPromptDebugSuffix } else { $GitPromptSettings.DefaultPromptSuffix } - - # If user specifies $null or empty string, set to ' ' to avoid "PS>" unexpectedly being displayed - if (!$promptSuffix) { - $promptSuffix = ' ' - } - - $expandedPromptSuffix = $ExecutionContext.SessionState.InvokeCommand.ExpandString($promptSuffix) - - # If prompt timing enabled, display elapsed milliseconds - if ($GitPromptSettings.DefaultPromptEnableTiming) { - $sw.Stop() - $elapsed = $sw.ElapsedMilliseconds - Write-Prompt " ${elapsed}ms" - } - - $global:LASTEXITCODE = $origLastExitCode - $expandedPromptSuffix -'@) - # Set the posh-git prompt as the default prompt - Set-Item Function:\prompt -Value $poshGitPromptScriptBlock + Set-Item Function:\prompt -Value $GitPromptScriptBlock } # Install handler for removal/unload of the module @@ -127,7 +125,7 @@ $ExecutionContext.SessionState.Module.OnRemove = { # Check if the posh-git prompt function itself has been replaced. If so, do not restore the prompt function $promptDef = if ($funcInfo = Get-Command prompt -ErrorAction SilentlyContinue) { $funcInfo.Definition } - if ($promptDef -eq $poshGitPromptScriptBlock) { + if ($promptDef -eq $GitPromptScriptBlock) { Set-Item Function:\prompt -Value ([scriptblock]::Create($defaultPromptDef)) return } @@ -157,6 +155,9 @@ $exportModuleMemberParams = @{ 'Update-AllBranches', 'tgit' ) + Variable = @( + 'GitPromptScriptBlock' + ) } Export-ModuleMember @exportModuleMemberParams From e356d3b060af8b009ea9c17e27c58d6e9da498fd Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 12 Dec 2017 21:15:53 +0000 Subject: [PATCH 3/8] autofix PSSA warnings whilst preserving the encoding --- chocolatey/packAndLocalInstall.ps1 | 4 ++-- chocolatey/tests/InstallChocolatey.Tests.ps1 | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/chocolatey/packAndLocalInstall.ps1 b/chocolatey/packAndLocalInstall.ps1 index 9c2a9a6b4..62a2cf5a3 100644 --- a/chocolatey/packAndLocalInstall.ps1 +++ b/chocolatey/packAndLocalInstall.ps1 @@ -1,5 +1,5 @@ param ($Remote = 'origin', [switch]$Force) -pushd $PSScriptRoot +Push-Location $PSScriptRoot $nuspec = [xml](Get-Content poshgit.nuspec) $version = $nuspec.package.metadata.version @@ -17,4 +17,4 @@ elseif (!$(git ls-remote $Remote $tag)) { choco pack poshgit.nuspec choco install -f -y poshgit -pre --version=$version -s . -popd +Pop-Location diff --git a/chocolatey/tests/InstallChocolatey.Tests.ps1 b/chocolatey/tests/InstallChocolatey.Tests.ps1 index fe470feec..d8c2b2e73 100644 --- a/chocolatey/tests/InstallChocolatey.Tests.ps1 +++ b/chocolatey/tests/InstallChocolatey.Tests.ps1 @@ -39,7 +39,7 @@ Describe "Install-Posh-Git" { RunInstall $newProfile = (Get-Content $Profile) - $pgitDir = [Array](Dir "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime)[-1] + $pgitDir = [Array](Get-ChildItem "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime)[-1] ($newProfile -like ". '$poshgitPath\posh-git\profile.example.ps1'").Count.should.be(0) ($newProfile -like ". '$pgitDir\profile.example.ps1'").Count.should.be(1) } @@ -59,7 +59,7 @@ Describe "Install-Posh-Git" { RunInstall $newProfile = (Get-Content $Profile) - $pgitDir = [Array](Dir "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime)[-1] + $pgitDir = [Array](Get-ChildItem "$poshgitPath\*posh-git*\" | Sort-Object -Property LastWriteTime)[-1] ($newProfile -like ". '$pgitDir\profile.example.ps1'").Count.should.be(1) } catch { @@ -94,7 +94,7 @@ Describe "Install-Posh-Git" { try{ RunInstall mkdir PoshTest - Pushd PoshTest + Push-Location PoshTest git init . $Profile $global:wh="" @@ -102,7 +102,7 @@ Describe "Install-Posh-Git" { Prompt - Popd + Pop-Location $wh.should.be("$pwd\PoshTest [master]") } catch { @@ -122,7 +122,7 @@ Describe "Install-Posh-Git" { Remove-Item $Profile -Force RunInstall mkdir PoshTest - Pushd PoshTest + Push-Location PoshTest git init . $Profile $global:wh="" @@ -130,7 +130,7 @@ Describe "Install-Posh-Git" { Prompt - Popd + Pop-Location $wh.should.be("$pwd\PoshTest [master]") } catch { @@ -152,7 +152,7 @@ Describe "Install-Posh-Git" { Add-Content $profile -value "function prompt {Write-Host 'Hi'}" -Force RunInstall mkdir PoshTest - Pushd PoshTest + Push-Location PoshTest git init . $Profile $global:wh="" @@ -161,7 +161,7 @@ Describe "Install-Posh-Git" { Prompt Remove-Item function:\global:Write-Host - Popd + Pop-Location $wh.should.be("$pwd\PoshTest [master]") } catch { @@ -183,7 +183,7 @@ Describe "Install-Posh-Git" { Add-Content $profile -value ". 'C:\tools\poshgit\dahlbyk-posh-git-60be436\profile.example.ps1'" -Force RunInstall mkdir PoshTest - Pushd PoshTest + Push-Location PoshTest git init write-output (Get-Content function:\prompt) . $Profile @@ -193,7 +193,7 @@ Describe "Install-Posh-Git" { Prompt Remove-Item function:\global:Write-Host - Popd + Pop-Location $wh.should.be("$pwd\PoshTest [master]") } catch { From 74ec4d2be8f894e0bf8b4be5d0b05c295ac5a3fa Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Tue, 9 Jan 2018 21:57:19 -0600 Subject: [PATCH 4/8] Add DefaultPromptPath setting And export Get-PromptPath to expose our default path logic --- src/GitPrompt.ps1 | 2 ++ src/Utils.ps1 | 21 +++++++++++++++++++++ src/posh-git.psd1 | 1 + src/posh-git.psm1 | 24 ++---------------------- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/GitPrompt.ps1 b/src/GitPrompt.ps1 index 010af199c..a11037f0c 100644 --- a/src/GitPrompt.ps1 +++ b/src/GitPrompt.ps1 @@ -104,6 +104,8 @@ $global:GitPromptSettings = [pscustomobject]@{ DefaultPromptSuffix = '$(''>'' * ($nestedPromptLevel + 1)) ' DefaultPromptDebugSuffix = ' [DBG]$(''>'' * ($nestedPromptLevel + 1)) ' DefaultPromptEnableTiming = $false + + DefaultPromptPath = '$(Get-PromptPath)' DefaultPromptAbbreviateHomeDirectory = $false Debug = $false diff --git a/src/Utils.ps1 b/src/Utils.ps1 index 8a96e982d..64623676b 100644 --- a/src/Utils.ps1 +++ b/src/Utils.ps1 @@ -275,6 +275,27 @@ function Get-PathStringComparison { } } +function Get-PromptPath { + $settings = $global:GitPromptSettings + $abbrevHomeDir = $settings -and $settings.DefaultPromptAbbreviateHomeDirectory + + # A UNC path has no drive so it's better to use the ProviderPath e.g. "\\server\share". + # However for any path with a drive defined, it's better to use the Path property. + # In this case, ProviderPath is "\LocalMachine\My"" whereas Path is "Cert:\LocalMachine\My". + # The latter is more desirable. + $pathInfo = $ExecutionContext.SessionState.Path.CurrentLocation + $currentPath = if ($pathInfo.Drive) { $pathInfo.Path } else { $pathInfo.ProviderPath } + + $stringComparison = Get-PathStringComparison + + # Abbreviate path by replacing beginning of path with ~ *iff* the path is in the user's home dir + if ($abbrevHomeDir -and $currentPath -and $currentPath.StartsWith($Home, $stringComparison)) { + $currentPath = "~" + $currentPath.SubString($Home.Length) + } + + return $currentPath +} + function Get-PSModulePath { $modulePaths = $Env:PSModulePath -split ';' $modulePaths diff --git a/src/posh-git.psd1 b/src/posh-git.psd1 index 775f11b84..e95fcd45e 100644 --- a/src/posh-git.psd1 +++ b/src/posh-git.psd1 @@ -25,6 +25,7 @@ PowerShellVersion = '2.0' FunctionsToExport = @( 'Invoke-NullCoalescing', 'Add-PoshGitToProfile', + 'Get-PromptPath', 'Write-GitStatus', 'Write-Prompt', 'Write-VcsStatus', diff --git a/src/posh-git.psm1 b/src/posh-git.psm1 index fb141dfc4..93940e32b 100644 --- a/src/posh-git.psm1 +++ b/src/posh-git.psm1 @@ -41,28 +41,6 @@ $GitPromptScriptBlock = { } $origLastExitCode = $global:LASTEXITCODE - # A UNC path has no drive so it's better to use the ProviderPath e.g. "\\server\share". - # However for any path with a drive defined, it's better to use the Path property. - # In this case, ProviderPath is "\LocalMachine\My"" whereas Path is "Cert:\LocalMachine\My". - # The latter is more desirable. - $pathInfo = $ExecutionContext.SessionState.Path.CurrentLocation - $currentPath = if ($pathInfo.Drive) { $pathInfo.Path } else { $pathInfo.ProviderPath } - - # File system paths are case-sensitive on Linux and case-insensitive on Windows and macOS - if (($PSVersionTable.PSVersion.Major -ge 6) -and $IsLinux) { - $stringComparison = [System.StringComparison]::Ordinal - } - else { - $stringComparison = [System.StringComparison]::OrdinalIgnoreCase - } - - # Abbreviate path by replacing beginning of path with ~ *iff* the path is in the user's home dir - $abbrevHomeDir = $GitPromptSettings.DefaultPromptAbbreviateHomeDirectory - if ($abbrevHomeDir -and $currentPath -and $currentPath.StartsWith($Home, $stringComparison)) - { - $currentPath = "~" + $currentPath.SubString($Home.Length) - } - # Display default prompt prefix if not empty. $defaultPromptPrefix = [string]$GitPromptSettings.DefaultPromptPrefix if ($defaultPromptPrefix) { @@ -71,6 +49,7 @@ $GitPromptScriptBlock = { } # Write the abbreviated current path + $currentPath = $ExecutionContext.SessionState.InvokeCommand.ExpandString($GitPromptSettings.DefaultPromptPath) Write-Prompt $currentPath # Write the Git status summary information @@ -138,6 +117,7 @@ $exportModuleMemberParams = @{ Function = @( 'Invoke-NullCoalescing', 'Add-PoshGitToProfile', + 'Get-PromptPath', 'Write-GitStatus', 'Write-Prompt', 'Write-VcsStatus', From 6b0de009254ba0540b26a36f3c6e4aeb4f08acda Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Wed, 10 Jan 2018 01:36:21 -0600 Subject: [PATCH 5/8] Update changelog for 0.7.2 --- CHANGELOG.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec8ab7ef4..0fc0fd450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,60 @@ # posh-git Release History +## 0.7.2 - January 10, 2018 + +- posh-git now exports the variable `$GitPromptScriptBlock` which contains the code for the default prompt. + ([#501](https://github.com/dahlbyk/posh-git/issues/501)) + ([PR #513](https://github.com/dahlbyk/posh-git/pull/513)) + + If you need to execute your own logic in your own prompt function but still want to display the default posh-git + prompt, you can execute this scriptblock from your prompt function e.g.: + + ```powershell + # profile.ps1 + function prompt { + Set-NodeVersion + &$GitPromptScriptBlock + } + Import-Module posh-git + ``` + +- Added `Add-PoshGitToProfile -AllUsers` support + ([PR #504](https://github.com/dahlbyk/posh-git/pull/504)) +- Fixed 'Write-Prompt' to be able use Black as foreground color. + ([#470](https://github.com/dahlbyk/posh-git/pull/470)) + ([PR #468](https://github.com/dahlbyk/posh-git/pull/468)) + Thanks Vladimir Poleh (@vladimir-poleh) +- Pass "git.exe" instead of "git" to Get-Command. + ([PR #478](https://github.com/dahlbyk/posh-git/pull/478)) + ([PR #479](https://github.com/dahlbyk/posh-git/pull/479)) + Thanks Mike Sigsworth (@mikesigs) +- Squash ssh agent warnings if `-Quiet`. + ([PR #484](https://github.com/dahlbyk/posh-git/pull/484)) + Thanks Refael Ackermann (@refack) +- Fixed directory names that contain [brackets] cause GitPrompt to fail. + ([PR #502](https://github.com/dahlbyk/posh-git/pull/502)) + Thanks Duncan Smart (@duncansmart) +- Fixed duplicated branch completion for git checkout + ([#505](https://github.com/dahlbyk/posh-git/issues/505)) + ([PR #506](https://github.com/dahlbyk/posh-git/pull/506)) + ([PR #512](https://github.com/dahlbyk/posh-git/pull/512)) + Thanks Christoph Bergmeister (@bergmeister) +- Fixed PSScriptAnalyzer warnings in the source + ([PR #509](https://github.com/dahlbyk/posh-git/pull/509)) + Thanks Christoph Bergmeister (@bergmeister) +- Fixed errors added to $Error collection by `Get-GitStatus` command + ([#500](https://github.com/dahlbyk/posh-git/issues/500)) + ([PR #514](https://github.com/dahlbyk/posh-git/pull/514)) +- Add custom path rendering in prompt + ([#469](https://github.com/dahlbyk/posh-git/issues/469)) + ([PR #520](https://github.com/dahlbyk/posh-git/pull/520)) +- Clean up wording for work dir local status in help file + ([PR #516](https://github.com/dahlbyk/posh-git/pull/516)) +- Add code coverage to Coveralls.io + ([#416](https://github.com/dahlbyk/posh-git/pull/416)) + ([PR #461](https://github.com/dahlbyk/posh-git/pull/461)) + Thanks Jan De Dobbeleer (@JanJoris) + ## 0.7.1 - March 14, 2017 - Fixed tab completion issues with duplicate aliases From 21fb58ac540a6b714a146aaa91d1631df1cb356d Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Tue, 9 Jan 2018 22:38:41 -0700 Subject: [PATCH 6/8] Update CHANGELOG for 1.0.0-beta1 release --- CHANGELOG.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0dc9a7e5..3a12b865c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,76 @@ # posh-git Release History -## 1.0.0 - TBD -This release introduces breaking changes with 0.x to both drop support for PowerShell 2.0 and support writing prompt strings using ANSI sequences. -The ANSI sequence support will help with cross-platform PowerShell support, which is another goal of this release. +## 1.0.0-beta1 - January 10, 2018 + +The 1.0.0 release is targeted specifically at Windows PowerShell 5.x and (cross-platform) PowerShell Core 6.x, both of +which support writing prompt strings using [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code). +On Windows, support for [Console Virtual Terminal Sequences](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) +was added in Windows 10 version 1511. +Consequently this release introduces BREAKING changes with 0.7.x by: + +- Dropping support for Windows PowerShell versions 2.0, 3.0 and 4.0. +- Changing the $GitPromptSettings hashtable to a more structured and stongly typed object. + Here is one example of the changed settings structure: + ```powershell + $GitPromptSettings.LocalWorkingStatusSymbol = '#' + $GitPromptSettings.LocalWorkingStatusForegroundColor = [ConsoleColor]::DarkRed + ``` + Changes to: + ```powershell + $GitPromptSettings.LocalWorkingStatusSymbol.Text = '#' + $GitPromptSettings.LocalWorkingStatusSymbol.ForegroundColor = [ConsoleColor]::DarkRed + ``` +- Changing `Write-VcsStatus`, `Write-GitStatus` and `Write-Prompt` to return a string rather than write to host when + the host supports ANSI escape sequences. + +If you are still on Windows PowerShell 2.0, 3.0 or 4.0, please continue to use the 0.7.x version of posh-git. + +### Removed - Drop support for PowerShell 2.0 ([#163](https://github.com/dahlbyk/posh-git/issues/163)) ([PR #427](https://github.com/dahlbyk/posh-git/pull/427)) -- Remove public `Enable-GitColors`, `Get-AliasPattern` and `Get-GitBranch`; plus `Invoke-NullCoalescing` and its `??` alias +- Drop support for PowerShell 3.0 and 4.0 + ([#328](https://github.com/dahlbyk/posh-git/issues/328)) + ([PR #513](https://github.com/dahlbyk/posh-git/pull/513)) +- Remove public `Enable-GitColors`, `Get-AliasPattern`, `Get-GitBranch` and `Invoke-NullCoalescing` and its `??` alias ([#93](https://github.com/dahlbyk/posh-git/issues/93)) ([PR #427](https://github.com/dahlbyk/posh-git/pull/427)) +### Added + +- Implement support for ANSI escape sequences for colored output - support System.ConsoleColor, System.Drawing.HtmlColor + (if available on the platform) and 24-bit color. NOTE: this is a breaking change since `Write-VcsStatus`, + `Write-GitStatus` and `Write-Prompt` will now return a string rather than write to the host when the host supports + ANSI escape sequences. + ([#304](https://github.com/dahlbyk/posh-git/pull/304)) + ([#447](https://github.com/dahlbyk/posh-git/pull/447)) + ([#455](https://github.com/dahlbyk/posh-git/pull/455)) +- $GitPromptSettings is now a strongly typed object using PS classes + ([#344](https://github.com/dahlbyk/posh-git/issues/344)) + ([PR #513](https://github.com/dahlbyk/posh-git/pull/513)) +- Provide more granular commands than just `Write-GitStatus`. + ([#345](https://github.com/dahlbyk/posh-git/issues/345)) + ([PR #513](https://github.com/dahlbyk/posh-git/pull/513)) + We now export the commands that `Write-GitStatus` uses internally which are: + * Write-GitBranchName + * Write-GitBranchStatus + * Write-GitIndexStatus + * Write-GitStashCount + * Write-GitWorkingDirStatus + * Write-GitWorkingDirStatusSummary + +### Fixed + +- Fixed Get-AuthenticodeSignature not on PS Core. + ([PR #487](https://github.com/dahlbyk/posh-git/pull/487)) +- Provide DefaultPromptPrefixColor and DefaultPromptSuffixColor options + ([#474](https://github.com/dahlbyk/posh-git/issues/474)) + ([PR #520](https://github.com/dahlbyk/posh-git/pull/520)) +- Fixed posh-git prompt makes PowerShell transcripts less readable + ([#282](https://github.com/dahlbyk/posh-git/issues/282)) + ([PR #447](https://github.com/dahlbyk/posh-git/pull/447)) + ## 0.7.2 - January 10, 2018 - posh-git now exports the variable `$GitPromptScriptBlock` which contains the code for the default prompt. From 5fb7518085796fdad50ec48bd7afb91f41d8bbee Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Wed, 10 Jan 2018 03:13:08 -0600 Subject: [PATCH 7/8] Bump to 1.0.0-beta1 --- chocolatey/poshgit.nuspec | 4 ++-- src/posh-git.psd1 | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/chocolatey/poshgit.nuspec b/chocolatey/poshgit.nuspec index 01141ef04..c97ec6706 100644 --- a/chocolatey/poshgit.nuspec +++ b/chocolatey/poshgit.nuspec @@ -3,7 +3,7 @@ poshgit posh-git - 1.0.0-pre00 + 1.0.0-beta1 Keith Dahlby, Mark Embling, Jeremy Skinner, Keith Hill Keith Dahlby ### posh-git @@ -27,7 +27,7 @@ Note on performance: displaying file status in the git prompt for a very large r Provides prompt with Git status summary information and tab completion for Git commands, parameters, remotes and branch names. poshgit posh-git powershell git https://github.com/dahlbyk/posh-git - https://github.com/dahlbyk/posh-git/blob/develop/LICENSE.txt + https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta1/LICENSE.txt false diff --git a/src/posh-git.psd1 b/src/posh-git.psd1 index 9d1e2e03b..458efafb1 100644 --- a/src/posh-git.psd1 +++ b/src/posh-git.psd1 @@ -65,16 +65,16 @@ PrivateData = @{ Tags = @('git', 'prompt', 'tab', 'tab-completion', 'tab-expansion', 'tabexpansion') # A URL to the license for this module. - LicenseUri = 'https://github.com/dahlbyk/posh-git/blob/develop/LICENSE.txt' + LicenseUri = 'https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta1/LICENSE.txt' # A URL to the main website for this project. ProjectUri = 'https://github.com/dahlbyk/posh-git' # ReleaseNotes of this module - ReleaseNotes = 'https://github.com/dahlbyk/posh-git/blob/develop/CHANGELOG.md' + ReleaseNotes = 'https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta1/CHANGELOG.md' # OVERRIDE THIS FIELD FOR PUBLISHED RELEASES - LEAVE AT 'alpha' FOR CLONED/LOCAL REPO USAGE - Prerelease = 'alpha' + Prerelease = 'beta1' } } From 9a9b8c1435f30bfe0d0689e88e04b9d7058380ed Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Fri, 12 Jan 2018 15:25:09 -0600 Subject: [PATCH 8/8] Reset after v1.0.0-beta1; beta2 is next? --- chocolatey/poshgit.nuspec | 2 +- src/posh-git.psd1 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chocolatey/poshgit.nuspec b/chocolatey/poshgit.nuspec index c97ec6706..0c24c2b47 100644 --- a/chocolatey/poshgit.nuspec +++ b/chocolatey/poshgit.nuspec @@ -27,7 +27,7 @@ Note on performance: displaying file status in the git prompt for a very large r Provides prompt with Git status summary information and tab completion for Git commands, parameters, remotes and branch names. poshgit posh-git powershell git https://github.com/dahlbyk/posh-git - https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta1/LICENSE.txt + https://github.com/dahlbyk/posh-git/blob/develop/LICENSE.txt false diff --git a/src/posh-git.psd1 b/src/posh-git.psd1 index 458efafb1..bb91b7a8b 100644 --- a/src/posh-git.psd1 +++ b/src/posh-git.psd1 @@ -65,16 +65,16 @@ PrivateData = @{ Tags = @('git', 'prompt', 'tab', 'tab-completion', 'tab-expansion', 'tabexpansion') # A URL to the license for this module. - LicenseUri = 'https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta1/LICENSE.txt' + LicenseUri = 'https://github.com/dahlbyk/posh-git/blob/develop/LICENSE.txt' # A URL to the main website for this project. ProjectUri = 'https://github.com/dahlbyk/posh-git' # ReleaseNotes of this module - ReleaseNotes = 'https://github.com/dahlbyk/posh-git/blob/v1.0.0-beta1/CHANGELOG.md' + ReleaseNotes = 'https://github.com/dahlbyk/posh-git/blob/develop/CHANGELOG.md' # OVERRIDE THIS FIELD FOR PUBLISHED RELEASES - LEAVE AT 'alpha' FOR CLONED/LOCAL REPO USAGE - Prerelease = 'beta1' + Prerelease = 'beta1x' } }