Skip to content

Commit

Permalink
Merge pull request #458 from dahlbyk/master
Browse files Browse the repository at this point in the history
Update develop from master
  • Loading branch information
dahlbyk committed Mar 5, 2017
2 parents d42d7a7 + 0f5a937 commit 48e2c28
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Expand Up @@ -21,7 +21,7 @@
"type": "PowerShell",
"request": "attach",
"name": "PowerShell Attach to Host Process",
"processId": "${command.PickPSHostProcess}",
"processId": "${command:PickPSHostProcess}",
"runspaceId": 1
}
]
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,13 @@ The ANSI sequence support will help with cross-platform PowerShell support, whic
([PR #425](https://github.com/dahlbyk/posh-git/pull/425))
- Fix Chocolatey deprecation warning with dependency on 0.9.10
([PR #426](https://github.com/dahlbyk/posh-git/pull/426))
- Don't rerun Pageant if there are no keys to add
([PR #441](https://github.com/dahlbyk/posh-git/pull/441))
- Improve (and hide for Chocolatey) profile.example.ps1 deprecation messaging
([#442](https://github.com/dahlbyk/posh-git/issues/442))
([PR #444](https://github.com/dahlbyk/posh-git/pull/444))
- Quote tab completion for remote names containing special characters
([PR #446](https://github.com/dahlbyk/posh-git/pull/446))

## 0.7.0 - February 14, 2017
This release has focused on improving the "getting started" experience by adding an `Add-PoshGitToProfile` command that
Expand Down Expand Up @@ -116,6 +123,12 @@ Work was begun to eliminate some obvious crashes on PowerShell on .NET Core but
- Add support for tab-completion of Git parameters, long and short
([PR #395](https://github.com/dahlbyk/posh-git/pull/395))
- Switch `$GitPromptSettings` type from `PSObject` to `PSCustomObject`. On PowerShell v5 and higher, this preserves the definition order of properties in `$GitPromptSettings` making it easier to find properties.
- Fix prompt status in worktree
([#407](https://github.com/dahlbyk/posh-git/issues/407))
([PR #408](https://github.com/dahlbyk/posh-git/pull/408))
- Quote tab completion for items containing special characters
([#293](https://github.com/dahlbyk/posh-git/issues/293))
([PR #413](https://github.com/dahlbyk/posh-git/pull/413))

## Thank You:
Thank you to the following folks who contributed their time and scripting skills to make posh-git better:
Expand Down
4 changes: 2 additions & 2 deletions install.ps1
@@ -1,6 +1,6 @@
param([switch]$WhatIf = $false, [switch]$Force = $false)
param([switch]$WhatIf = $false, [switch]$Force = $false, [switch]$Verbose = $false)

$installDir = Split-Path $MyInvocation.MyCommand.Path -Parent

Import-Module $installDir\src\posh-git.psd1
Add-PoshGitToProfile -WhatIf:$WhatIf -Force:$Force
Add-PoshGitToProfile -WhatIf:$WhatIf -Force:$Force -Verbose:$Verbose
4 changes: 3 additions & 1 deletion src/GitTabExpansion.ps1
Expand Up @@ -81,7 +81,9 @@ function script:gitCommands($filter, $includeAliases) {
}

function script:gitRemotes($filter) {
git remote | Where-Object { $_ -like "$filter*" }
git remote |
Where-Object { $_ -like "$filter*" } |
quoteStringWithSpecialChars
}

function script:gitBranches($filter, $includeHEAD = $false, $prefix = '') {
Expand Down
10 changes: 9 additions & 1 deletion src/Utils.ps1
Expand Up @@ -161,7 +161,7 @@ function Add-PoshGitToProfile {
# If the profile script exists and is signed, then we should not modify it
if (Test-Path -LiteralPath $profilePath) {
$sig = Get-AuthenticodeSignature $profilePath
if ($sig.SignatureType -eq [System.Management.Automation.SignatureType]::Authenticode) {
if ($null -ne $sig.SignerCertificate) {
Write-Warning "Skipping add of posh-git import to profile; '$profilePath' appears to be signed."
Write-Warning "Add the command 'Import-Module posh-git' to your profile and resign it."
return
Expand All @@ -176,6 +176,14 @@ function Add-PoshGitToProfile {
$profileContent = "`nImport-Module '$ModuleBasePath\posh-git.psd1'"
}

# Make sure the PowerShell profile directory exists
$profileDir = Split-Path $profilePath -Parent
if (!(Test-Path -LiteralPath $profileDir)) {
if ($PSCmdlet.ShouldProcess($profileDir, "Create current user PowerShell profile directory")) {
New-Item $profileDir -ItemType Directory -Force -Verbose:$VerbosePreference > $null
}
}

if ($PSCmdlet.ShouldProcess($profilePath, "Add 'Import-Module posh-git' to profile")) {
Add-Content -LiteralPath $profilePath -Value $profileContent -Encoding UTF8
}
Expand Down
10 changes: 9 additions & 1 deletion test/TabExpansion.Tests.ps1
Expand Up @@ -10,8 +10,10 @@ Describe 'TabExpansion Tests' {
git branch -q master origin/master 2>$null
}
It 'Tab completes all remotes' {
(git remote) -contains 'origin' | Should Be $true

$result = & $module GitTabExpansionInternal 'git push '
$result | Should BeExactly (git remote)
$result -contains 'origin' | Should Be $true
}
It 'Tab completes all branches' {
$result = & $module GitTabExpansionInternal 'git push origin '
Expand Down Expand Up @@ -207,6 +209,12 @@ Describe 'TabExpansion Tests' {
AfterEach {
ResetGitTempRepoWorkingDir $repoPath
}
It 'Tab completes remote name with special char as quoted' {
git.exe remote add '#test' https://github.com/dahlbyk/posh-git.git 2> $null

$result = & $module GitTabExpansionInternal 'git push #'
$result | Should BeExactly "'#test'"
}
It 'Tab completes branch name with special char as quoted' {
git.exe branch '#develop' 2>$null

Expand Down
14 changes: 13 additions & 1 deletion test/Utils.Tests.ps1
Expand Up @@ -12,7 +12,7 @@ Describe 'Utils Function Tests' {
$profilePath = [System.IO.Path]::GetTempFileName()
}
AfterEach {
Remove-Item $profilePath -ErrorAction SilentlyContinue
Remove-Item $profilePath -Recurse -ErrorAction SilentlyContinue
}
It 'Creates profile file if it does not exist that imports absolute path' {
Mock Get-PSModulePath {
Expand Down Expand Up @@ -50,6 +50,18 @@ Describe 'Utils Function Tests' {
$content.Count | Should Be 2
@($content)[1] | Should BeExactly "Import-Module posh-git"
}
It 'Creates profile file if the profile dir does not exist' {
# Use $profilePath as missing parent directory (auto-cleanup)
Remove-Item -LiteralPath $profilePath
Test-Path -LiteralPath $profilePath | Should Be $false

$childProfilePath = Join-Path $profilePath profile.ps1

Add-PoshGitToProfile $childProfilePath

Test-Path -LiteralPath $childProfilePath | Should Be $true
$childProfilePath | Should Contain "^Import-Module .*posh-git"
}
It 'Does not modify profile that already refers to posh-git' {
$profileContent = @'
Import-Module PSCX
Expand Down

0 comments on commit 48e2c28

Please sign in to comment.