Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test Posh-Git

on: [push, pull_request]

jobs:
test:
strategy:
fail-fast: false
matrix:
os: ['windows-latest', 'macos-latest', 'ubuntu-latest']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: install dependencies
shell: pwsh
run: |
"Git version: $(git --version)"
"PSVersion: $($PSVersionTable.PSVersion)"
"Host name: $($Host.Name)"

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module Pester -MinimumVersion 5.0.0 -MaximumVersion 5.99.99 -Scope CurrentUser -Force
- name: run tests
shell: pwsh
run: |
Import-Module Pester -PassThru
$ErrorActionPreference = 'Continue'
$res = Invoke-Pester -Path test -Output Detailed -PassThru -ErrorAction SilentlyContinue
if (!$res -or ($res.FailedCount -gt 0)) {
$Error | Format-List * -Force
exit 1
}
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

64 changes: 0 additions & 64 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion test/DefaultPrompt.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ M test/Baz.Tests.ps1
$title | Should -match '^Windows PowerShell|:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe$'
}
else {
$title | Should -match '^(Windows )?PowerShell'
$title | Should -match '^(Administrator: )?(Windows )?PowerShell'
}
}
}
Expand Down
60 changes: 30 additions & 30 deletions test/GitProxyFunctionExpansion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,34 @@ Describe 'Proxy Function Expansion Tests' {
}
}
It 'Expands a proxy function with parameters' {
function script:Invoke-GitFunction { git checkout $args }
function global:Invoke-GitFunction { git checkout $args }
$result = & $module Expand-GitProxyFunction 'Invoke-GitFunction -b newbranch'
$result | Should -Be 'git checkout -b newbranch'
$result | Should -Be (& $module Expand-GitProxyFunction 'igf -b newbranch')
}
It 'Expands a multiline proxy function' {
function script:Invoke-GitFunction { git checkout $args }
function global:Invoke-GitFunction { git checkout $args }
$result = & $module Expand-GitProxyFunction "Invoke-GitFunction ```r`n-b ```r`nnewbranch"
$result | Should -Be 'git checkout -b newbranch'
$result | Should -Be (& $module Expand-GitProxyFunction "igf ```r`n-b ```r`nnewbranch")
}
It 'Does not expand the proxy function name if there is no preceding whitespace before backtick newlines' {
function script:Invoke-GitFunction { git checkout $args }
function global:Invoke-GitFunction { git checkout $args }
& $module Expand-GitProxyFunction "Invoke-GitFunction```r`n-b```r`nnewbranch" | Should -Be "Invoke-GitFunction```r`n-b```r`nnewbranch"
& $module Expand-GitProxyFunction "igf```r`n-b```r`nnewbranch" | Should -Be "igf```r`n-b```r`nnewbranch"
}
It 'Does not expand the proxy function name if there is no preceding non-newline whitespace before any backtick newlines' {
function script:Invoke-GitFunction { git checkout $args }
function global:Invoke-GitFunction { git checkout $args }
& $module Expand-GitProxyFunction "Invoke-GitFunction ```r`n-b```r`nnewbranch" | Should -Be "Invoke-GitFunction ```r`n-b```r`nnewbranch"
& $module Expand-GitProxyFunction "igf ```r`n-b```r`nnewbranch" | Should -Be "igf ```r`n-b```r`nnewbranch"
}
It 'Does not expand the proxy function name if the preceding whitespace before backtick newlines are newlines' {
function script:Invoke-GitFunction { git checkout $args }
function global:Invoke-GitFunction { git checkout $args }
& $module Expand-GitProxyFunction "Invoke-GitFunction`r`n```r`n-b`r`n```r`nnewbranch" | Should -Be "Invoke-GitFunction`r`n```r`n-b`r`n```r`nnewbranch"
& $module Expand-GitProxyFunction "igf`r`n```r`n-b`r`n```r`nnewbranch" | Should -Be "igf`r`n```r`n-b`r`n```r`nnewbranch"
}
It 'Does not expand the proxy function if there is no trailing space' {
function script:Invoke-GitFunction { git checkout $args }
function global:Invoke-GitFunction { git checkout $args }
& $module Expand-GitProxyFunction 'Invoke-GitFunction' | Should -Be 'Invoke-GitFunction'
& $module Expand-GitProxyFunction 'igf' | Should -Be 'igf'
}
Expand Down Expand Up @@ -85,39 +85,39 @@ Describe 'Proxy Function Expansion Tests' {
}
}
It 'Expands a single line function' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git checkout $args
}
$result = & $module Expand-GitProxyFunction 'Invoke-GitFunction '
$result | Should -Be 'git checkout '
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands a single line function with short parameter' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git checkout -b $args
}
$result = & $module Expand-GitProxyFunction 'Invoke-GitFunction '
$result | Should -Be 'git checkout -b '
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands a single line function with long parameter' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git checkout --detach $args
}
$result = & $module Expand-GitProxyFunction 'Invoke-GitFunction '
$result | Should -Be 'git checkout --detach '
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands a single line with piped function suffix' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git checkout --detach $args | Write-Host
}
$result = & $module Expand-GitProxyFunction 'Invoke-GitFunction '
$result | Should -Be 'git checkout --detach '
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands the first line in function' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git checkout $args
$a = 5
Write-Host $null
Expand All @@ -127,7 +127,7 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands the middle line in function' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
$a = 5
git checkout $args
Write-Host $null
Expand All @@ -137,7 +137,7 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands the last line in function' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
$a = 5
Write-Host $null
git checkout $args
Expand All @@ -147,15 +147,15 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands semicolon delimited functions' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
$a = 5; git checkout $args; Write-Host $null;
}
$result = & $module Expand-GitProxyFunction 'Invoke-GitFunction '
$result | Should -Be 'git checkout '
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands mixed semicolon delimited and newline functions' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
$a = 5; Write-Host $null
git checkout $args; Write-Host $null;
}
Expand All @@ -164,7 +164,7 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands mixed semicolon delimited and newline multiline functions' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
$a = 5; Write-Host $null
git `
checkout `
Expand All @@ -175,7 +175,7 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands simultaneously semicolon delimited and newline functions' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
$a = 5;
Write-Host $null;
git checkout $args;
Expand All @@ -186,7 +186,7 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands multiline function' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git `
checkout `
$args
Expand All @@ -196,7 +196,7 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands multiline function that terminates with semicolon on new line' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git `
checkout `
$args `
Expand All @@ -207,7 +207,7 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands multiline function with short parameter' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git `
checkout `
-b `
Expand All @@ -218,7 +218,7 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Expands multiline function with long parameter' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git `
checkout `
--detach `
Expand All @@ -229,21 +229,21 @@ Describe 'Proxy Function Expansion Tests' {
$result | Should -Be (& $module Expand-GitProxyFunction 'igf ' )
}
It 'Does not expand a single line with piped function prefix' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
"master" | git checkout --detach $args
}
& $module Expand-GitProxyFunction 'Invoke-GitFunction ' | Should -Be 'Invoke-GitFunction '
& $module Expand-GitProxyFunction 'igf ' | Should -Be 'igf '
}
It 'Does not expand function if $args is not present' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
git checkout
}
& $module Expand-GitProxyFunction 'Invoke-GitFunction ' | Should -Be 'Invoke-GitFunction '
& $module Expand-GitProxyFunction 'igf ' | Should -Be 'igf '
}
It 'Does not expand function if $args is not attached to the git function' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
$a = 5
git checkout
Write-Host $args
Expand All @@ -252,7 +252,7 @@ Describe 'Proxy Function Expansion Tests' {
& $module Expand-GitProxyFunction 'igf ' | Should -Be 'igf '
}
It 'Does not expand multiline function if $args is not attached to the git function' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
$a = 5
git `
checkout
Expand All @@ -262,7 +262,7 @@ Describe 'Proxy Function Expansion Tests' {
& $module Expand-GitProxyFunction 'igf ' | Should -Be 'igf '
}
It 'Does not expand multiline function backtick newlines are not preceded with whitespace' {
function script:Invoke-GitFunction {
function global:Invoke-GitFunction {
$a = 5
git`
checkout`
Expand All @@ -278,7 +278,7 @@ Describe 'Proxy Function Expansion Tests' {
if(Test-Path -Path Function:\Invoke-GitFunction) {
Rename-Item -Path Function:\Invoke-GitFunction -NewName Invoke-GitFunctionBackup
}
function script:Invoke-GitFunction { git checkout $args }
function global:Invoke-GitFunction { git checkout $args }
}
AfterEach {
if(Test-Path -Path Function:\Invoke-GitFunction) {
Expand Down Expand Up @@ -320,14 +320,14 @@ Describe 'Proxy Function Expansion Tests' {
}
}
It 'Tab completes without subcommands' {
function script:Invoke-GitFunction { git whatever $args }
function global:Invoke-GitFunction { git whatever $args }
$functionText = & $module Expand-GitProxyFunction 'Invoke-GitFunction '
$result = & $module GitTabExpansionInternal $functionText

$result | Should -Be @()
}
It 'Tab completes bisect subcommands' {
function script:Invoke-GitFunction { git bisect $args }
function global:Invoke-GitFunction { git bisect $args }
$functionText = & $module Expand-GitProxyFunction 'Invoke-GitFunction '
$result = & $module GitTabExpansionInternal $functionText

Expand All @@ -342,7 +342,7 @@ Describe 'Proxy Function Expansion Tests' {
$result2 -contains 'skip' | Should -Be $true
}
It 'Tab completes remote subcommands' {
function script:Invoke-GitFunction { git remote $args }
function global:Invoke-GitFunction { git remote $args }
$functionText = & $module Expand-GitProxyFunction 'Invoke-GitFunction '
$result = & $module GitTabExpansionInternal $functionText

Expand Down