Skip to content

Commit

Permalink
Switched from git to &$gitbin in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
rkeithhill committed Jan 15, 2018
1 parent 8097c28 commit 6cc11d4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions chocolatey/tests/InstallChocolatey.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function Clean-Environment {
}

Describe "Install-Posh-Git" {

It "WillRemvePreviousInstallVersion" {
Setup-Environment
try{
Expand Down
10 changes: 5 additions & 5 deletions test/Get-GitDirectory.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ Describe 'Get-GitDiretory Tests' {
$repoPath = Join-Path $temp ([IO.Path]::GetRandomFileName())
$worktreePath = Join-Path $temp ([IO.Path]::GetRandomFileName())

git init $repoPath
&$gitbin init $repoPath
Set-Location $repoPath
'foo' > ./README.md
git add ./README.md
&$gitbin add ./README.md
# Quoting is a hack due to our use of the global:git function and how it converts args for invoke-expression
git commit -m "`"initial commit.`""
&$gitbin commit -m "`"initial commit.`""

if (Test-Path $worktreePath) {
Remove-Item $worktreePath -Recurse -Force
}
New-Item $worktreePath -ItemType Directory > $null
git worktree add -b test-worktree $worktreePath master 2>$null
&$gitbin worktree add -b test-worktree $worktreePath master 2>$null
}
AfterEach {
Set-Location $origPath
Expand Down Expand Up @@ -78,7 +78,7 @@ Describe 'Get-GitDiretory Tests' {
if (Test-Path $bareRepoPath) {
Remove-Item $bareRepoPath -Recurse -Force
}
git init --bare $bareRepoPath
&$gitbin init --bare $bareRepoPath
}
AfterAll {
Set-Location $origPath
Expand Down
2 changes: 1 addition & 1 deletion test/Shared.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function NewGitTempRepo([switch]$MakeInitialCommit) {

function RemoveGitTempRepo($RepoPath) {
Pop-Location
if (Test-Path $repoPath) {
if ($repoPath -and (Test-Path $repoPath)) {
Remove-Item $repoPath -Recurse -Force
}
}
Expand Down
32 changes: 16 additions & 16 deletions test/TabExpansion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Describe 'TabExpansion Tests' {
Context 'Fetch/Push/Pull TabExpansion Tests' {
BeforeEach {
# Ensure master branch exists
git branch -q master origin/master 2>$null
&$gitbin branch -q master origin/master 2>$null
}
It 'Tab completes all remotes' {
(git remote) -contains 'origin' | Should Be $true
(&$gitbin remote) -contains 'origin' | Should Be $true

$result = & $module GitTabExpansionInternal 'git push '
$result -contains 'origin' | Should Be $true
Expand Down Expand Up @@ -109,11 +109,11 @@ Describe 'TabExpansion Tests' {

It 'Tab completes branch names with - and -- in them' {
$branchName = 'branch--for-Pester-tests'
if (git branch --list -q $branchName) {
git branch -D $branchName
if (&$gitbin branch --list -q $branchName) {
&$gitbin branch -D $branchName
}

git branch $branchName
&$gitbin branch $branchName
try {
$result = & $module GitTabExpansionInternal 'git push origin branch-'
$result | Should BeExactly $branchName
Expand All @@ -122,7 +122,7 @@ Describe 'TabExpansion Tests' {
$result -contains $branchName | Should Be $true
}
finally {
git branch -D $branchName
&$gitbin branch -D $branchName
}
}
}
Expand All @@ -136,7 +136,7 @@ Describe 'TabExpansion Tests' {
RemoveGitTempRepo $repoPath
}
It 'Tab completes non-ASCII file name' {
git config core.quotepath true # Problematic (default) config
&$gitbin config core.quotepath true # Problematic (default) config

$fileName = "posh$([char]8226)git.txt"
New-Item $fileName -ItemType File
Expand All @@ -151,8 +151,8 @@ Describe 'TabExpansion Tests' {
Context 'Alias TabExpansion Tests' {
$addedAliases = @()
function Add-GlobalTestAlias($Name, $Value) {
if (!(git config --global "alias.$Name")) {
git config --global "alias.$Name" $Value
if (!(&$gitbin config --global "alias.$Name")) {
&$gitbin config --global "alias.$Name" $Value
$addedAliases += $Name
}
}
Expand All @@ -162,7 +162,7 @@ Describe 'TabExpansion Tests' {
}
AfterAll {
$addedAliases | Where-Object { $_ } | ForEach-Object {
git config --global --unset "alias.$_" 2>$null
&$gitbin config --global --unset "alias.$_" 2>$null
}

RemoveGitTempRepo $repoPath
Expand All @@ -171,8 +171,8 @@ Describe 'TabExpansion Tests' {
$alias = "test-$(New-Guid)"

Add-GlobalTestAlias $alias config
git config alias.$alias help
(git config --get-all alias.$alias).Count | Should Be 2
&$gitbin config alias.$alias help
(&$gitbin config --get-all alias.$alias).Count | Should Be 2

$result = @(& $module GitTabExpansionInternal "git $alias")
$result.Count | Should Be 1
Expand All @@ -181,17 +181,17 @@ Describe 'TabExpansion Tests' {
It 'Tab completes when there is one alias of a given name' {
$alias = "test-$(New-Guid)"

git config alias.$alias checkout
(git config --get-all alias.$alias).Count | Should Be 1
&$gitbin config alias.$alias checkout
(&$gitbin config --get-all alias.$alias).Count | Should Be 1

$result = & $module GitTabExpansionInternal "git $alias ma"
$result | Should BeExactly 'master'
}
It 'Tab completes when there are multiple aliases of the same name' {
Add-GlobalTestAlias co checkout

git config alias.co checkout
(git config --get-all alias.co).Count | Should BeGreaterThan 1
&$gitbin config alias.co checkout
(&$gitbin config --get-all alias.co).Count | Should BeGreaterThan 1

$result = & $module GitTabExpansionInternal 'git co ma'
$result | Should BeExactly 'master'
Expand Down

0 comments on commit 6cc11d4

Please sign in to comment.