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

Remove PowerShell v2 support. #427

Merged
merged 7 commits into from
Feb 20, 2017
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
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Pester Tests",
"script": "${workspaceRoot}/test/testDebugHarness.ps1",
"name": "PowerShell Pester Tests",
"script": "Invoke-Pester",
"args": [],
"cwd": "${file}"
"cwd": "${workspaceRoot}/test"
},
{
"type": "PowerShell",
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# 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.

- Drop support for PowerShell 2.0
- Remove Invoke-NullCoalescing command
([#93](https://github.com/dahlbyk/posh-git/issues/93))
([PR #426](https://github.com/dahlbyk/posh-git/pull/426))

## 0.7.0 - February 14, 2017
This release has focused on improving the "getting started" experience by adding an `Add-PoshGitToProfile` command that
modifies the user's PowerShell profile script to import the posh-git module whenever PowerShell starts.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Rather than turn off file status entirely (`$GitPromptSettings.EnableFileStatus
### Prerequisites
Before installing posh-git make sure the following prerequisites have been met.

1. PowerShell 2.0 or higher. Check your PowerShell version by executing `$PSVersionTable.PSVersion`.
1. PowerShell 3.0 or higher. Check your PowerShell version by executing `$PSVersionTable.PSVersion`.

2. Script execution policy must be set to either `RemoteSigned` or `Unrestricted`.
Check the script execution policy setting by executing `Get-ExecutionPolicy`.
Expand Down Expand Up @@ -58,7 +58,7 @@ Update-Module posh-git
```

### Installing posh-git via Chocolatey
If you have PowerShell version 2 or are having issues using Install-Module with PowerShell version 3 or 4, you can use [Chocolatey](https://chocolatey.org) to install posh-git.
If you are having issues using Install-Module with PowerShell version 3 or 4, you can use [Chocolatey](https://chocolatey.org) to install posh-git.
If you don't have Chocolatey, you can install it from the [Chocolately Install page](https://chocolatey.org/install).
With Chocolatey installed, execute the following command to install posh-git:
```
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ os:

branches:
only:
- master
- develop
Copy link
Owner

Choose a reason for hiding this comment

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

We probably want to keep both master and develop. That change may also need to find its way into master (the default branch) for it to take effect (not certain about that).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ideally there would be a way in appveyor.yml to specify the "current target branch". So if we put in both master and develop will that attempt to build a PR meant for develop on master also? If so, that would likely fail. Then again, I'm a total AppVeyor n00b.

Copy link
Owner

Choose a reason for hiding this comment

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

It just means any change in master or develop will be built. We will probably want to add a badge for develop, too.

PRs are built regardless of target; this setting is (ideally) only for merged PRs.


init:
- git config --global core.autocrlf true
Expand Down
2 changes: 1 addition & 1 deletion chocolatey/poshgit.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>poshgit</id>
<title>posh-git</title>
<version>0.7.0</version>
<version>1.0.0-pre00</version>
Copy link
Owner

Choose a reason for hiding this comment

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

👍

<authors>Keith Dahlby, Mark Embling, Jeremy Skinner, Keith Hill</authors>
<owners>Keith Dahlby</owners>
<description>### posh-git
Expand Down
6 changes: 4 additions & 2 deletions src/CheckVersion.ps1 → src/CheckRequirements.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ if (!(Get-Command git -TotalCount 1 -ErrorAction SilentlyContinue)) {
}

$requiredVersion = [Version]'1.7.2'
if ([String](git --version 2> $null) -match '(?<ver>\d+(?:\.\d+)+)') {
if ([string](git --version 2> $null) -match '(?<ver>\d+(?:\.\d+)+)') {
$version = [Version]$Matches['ver']
}

if ($version -lt $requiredVersion) {
Write-Warning "posh-git requires Git $requiredVersion or better. You have $version."
$false
} else {
}
else {
$true
}
27 changes: 13 additions & 14 deletions src/posh-git.psd1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@{

# Script module or binary module file associated with this manifest.
ModuleToProcess = 'posh-git.psm1'
RootModule = 'posh-git.psm1'

# Version number of this module.
ModuleVersion = '0.7.0'
ModuleVersion = '1.0.0'
Copy link
Owner

Choose a reason for hiding this comment

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

Really wish this supported a prerelease suffix. I'd like to be able to differentiate between folks using a PowerShell Gallery version and this branch. Maybe use 1.0.0.0 and then switch to 1.0.0 when the time comes to release?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

'1.0.0' comes out as version 1.0.0.-1 so the order between release and pre is wrong. :-(
We can add a field to the module manifest private data to indicate a PrereleaseVersion string that we could retrieve with (gmo posh-git).PrivateData.PSData.PrereleaseVersion.

Copy link
Owner

Choose a reason for hiding this comment

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

I am mostly concerned with the issue template version script showing a difference between loading from develop/master and from Chocolatey or the Gallery.

An alternative would be to include the posh-git module's path, perhaps with a replacement of $Home with ~?

Copy link
Owner

Choose a reason for hiding this comment

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

'1.0.0' comes out as version 1.0.0.-1 so the order between release and pre is wrong.

It may actually be desirable for a local version (think fork with personalized features) to win out over an official version (e.g. inherited from GitHub Desktop). Maybe? Of course the personalized fork could just bump the version...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The way I handle that scenario is to import by path e.g:

Import-Module $Home\GitHub\dahlbyk\posh-git\src\posh-git.psd1

Development is in the works for PowerShellGet/PSGallery to support prereleases. I'm hoping this problem will get solved in the coming months. PowerShell/PowerShell-RFC#42

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, but doing that if posh-git has already been loaded, e.g. in the GitHub Desktop shell, leaves you with two posh-git modules loaded. If one of those is 0.7.0 and the other is a personal fork that also reports 0.7.0, I have to check path to differentiate. Thus my suggestion of the extra .0 as a hint that this isn't an official version.

That said, also including PrereleaseVersion makes sense… add that to the issue template script?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK. But I'll update the issue template file on master in a separate PR. Also, regarding those extra commands to not export. I'll remove those. I'm guilty of adding Get-GitBranch for testing purposes but I think Pesters's InModuleScope will get me access to this function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What if we leave in Write-Prompt to abstract the difference between using Write-Host and ANSI escape sequences. Folks customizing their own prompt function might find that useful.


# ID used to uniquely identify this module
GUID = '74c9fd30-734b-4c89-a8ae-7727ad21d1d5'
Expand All @@ -19,27 +19,26 @@ Copyright = '(c) 2010-2017 Keith Dahlby and contributors'
Description = 'Provides prompt with Git status summary information and tab completion for Git commands, parameters, remotes and branch names.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '2.0'
PowerShellVersion = '3.0'

# Functions to export from this module
FunctionsToExport = @(
'Invoke-NullCoalescing',
'Add-PoshGitToProfile',
'Write-GitStatus',
'Write-Prompt',
'Write-VcsStatus',
'Enable-GitColors',
'Get-AliasPattern',
'Get-GitBranch',
'Get-GitStatus',
'Enable-GitColors',
'Get-GitDirectory',
'TabExpansion',
'Get-AliasPattern',
'Update-AllBranches',
'Write-GitStatus',
'Write-Prompt',
'Write-VcsStatus',
'Get-SshAgent',
'Start-SshAgent',
'Stop-SshAgent',
'Add-SshKey',
'Get-SshPath',
'Update-AllBranches',
'TabExpansion',
'tgit'
)

Expand All @@ -50,7 +49,7 @@ CmdletsToExport = @()
VariablesToExport = @()

# Aliases to export from this module
AliasesToExport = @('??')
AliasesToExport = @()
Copy link
Owner

Choose a reason for hiding this comment

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

Remove until we stumble on an alias we want to export (unlikely)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

An empty array helps with overall system performance.

If you omit the entry, PowerShell does more expensive work to see if you meant to export any aliases.


# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
Expand All @@ -61,13 +60,13 @@ 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/v0.7.0/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/v0.7.0/CHANGELOG.md'
ReleaseNotes = 'https://github.com/dahlbyk/posh-git/blob/develop/CHANGELOG.md'

} # End of PSData hashtable

Expand Down
41 changes: 14 additions & 27 deletions src/posh-git.psm1
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
param([switch]$NoVersionWarn,[switch]$ForcePoshGitPrompt)
param([switch]$NoVersionWarn, [switch]$ForcePoshGitPrompt)

if (Get-Module posh-git) { return }

$psv = $PSVersionTable.PSVersion

if ($psv.Major -lt 3 -and !$NoVersionWarn) {
Write-Warning ("posh-git support for PowerShell 2.0 is deprecated; you have version $($psv).`n" +
"To download version 5.0, please visit https://www.microsoft.com/en-us/download/details.aspx?id=50395`n" +
"For more information and to discuss this, please visit https://github.com/dahlbyk/posh-git/issues/163`n" +
"To suppress this warning, change your profile to include 'Import-Module posh-git -Args `$true'.")
}

& $PSScriptRoot\CheckVersion.ps1 > $null
& $PSScriptRoot\CheckRequirements.ps1 > $null

. $PSScriptRoot\Utils.ps1
. $PSScriptRoot\GitUtils.ps1
Expand All @@ -27,11 +16,12 @@ Get-TempEnv 'SSH_AGENT_PID'
Get-TempEnv 'SSH_AUTH_SOCK'

# Get the default prompt definition.
if (($psv.Major -eq 2) -or ![Runspace]::DefaultRunspace.InitialSessionState.Commands) {
$initialSessionState = [Runspace]::DefaultRunspace.InitialSessionState
if (!$initialSessionState.Commands -or !$initialSessionState.Commands['prompt']) {
$defaultPromptDef = "`$(if (test-path variable:/PSDebugContext) { '[DBG]: ' } else { '' }) + 'PS ' + `$(Get-Location) + `$(if (`$nestedpromptlevel -ge 1) { '>>' }) + '> '"
}
else {
$defaultPromptDef = [Runspace]::DefaultRunspace.InitialSessionState.Commands['prompt'].Definition
$defaultPromptDef = $initialSessionState.Commands['prompt'].Definition
}

# If there is no prompt function or the prompt function is the default, replace the current prompt function definition
Expand All @@ -44,8 +34,7 @@ if (!$currentPromptDef) {
}

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(@'
$poshGitPromptScriptBlock = {
if ($GitPromptSettings.DefaultPromptEnableTiming) {
$sw = [System.Diagnostics.Stopwatch]::StartNew()
}
Expand Down Expand Up @@ -107,7 +96,7 @@ if ($ForcePoshGitPrompt -or !$currentPromptDef -or ($currentPromptDef -eq $defau

$global:LASTEXITCODE = $origLastExitCode
$expandedPromptSuffix
'@)
}

# Set the posh-git prompt as the default prompt
Set-Item Function:\prompt -Value $poshGitPromptScriptBlock
Expand All @@ -128,25 +117,23 @@ $ExecutionContext.SessionState.Module.OnRemove = {
}

$exportModuleMemberParams = @{
Alias = @('??') # TODO: Remove in 1.0.0
Function = @(
'Invoke-NullCoalescing',
'Add-PoshGitToProfile',
'Enable-GitColors',
'Get-AliasPattern',
'Get-GitBranch',
'Get-GitDirectory',
'Get-GitStatus',
'Update-AllBranches',
'Write-GitStatus',
'Write-Prompt',
'Write-VcsStatus',
'Get-GitBranch',
'Get-GitStatus',
'Enable-GitColors',
'Get-GitDirectory',
'TabExpansion',
'Get-AliasPattern',
'Get-SshAgent',
'Start-SshAgent',
'Stop-SshAgent',
'Add-SshKey',
'Get-SshPath',
'Update-AllBranches',
'TabExpansion',
'tgit'
)
}
Expand Down
5 changes: 4 additions & 1 deletion test/Utils.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
Describe 'Utils Function Tests' {
Context 'Add-PoshGitToProfile Tests' {
BeforeAll {
$newLine = [System.Environment]::NewLine
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssigments', '')]
$newLine = [System.Environment]::NewLine
}
BeforeEach {
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssigments', '')]
$profilePath = [System.IO.Path]::GetTempFileName()
}
AfterEach {
Expand Down Expand Up @@ -84,6 +86,7 @@ New-Alias pscore C:\Users\Keith\GitHub\rkeithhill\PowerShell\src\powershell-win-

Context 'Test-PoshGitImportedInScript Tests' {
BeforeEach {
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssigments', '')]
$profilePath = [System.IO.Path]::GetTempFileName()
}
AfterEach {
Expand Down
2 changes: 0 additions & 2 deletions test/testDebugHarness.ps1

This file was deleted.