refactor(git): Use 'git -C' to specify the work directory instead of 'Push-Location'/'Pop-Location' (#4697)

* add `git_cmd`

-without any preset command/args

* remove unnecessary import

- `git.ps1`

* stop `Push-Location` and `Pop-Location` before/after git operations

* stop `Push-Location` and `Pop-Location` before/after git operations

* consistency of naming variable

* CHANGELOG

* punctuation mark

* remove functions that are no longer used

- `git_fetch`
- `git_pull`
- `get_checkout`
This commit is contained in:
HUMORCE
2022-02-01 15:46:45 +08:00
committed by GitHub
parent ba28a4f4f1
commit 5b0bdaf893
7 changed files with 45 additions and 69 deletions

View File

@@ -12,20 +12,17 @@ reset_aliases
$commands = commands
if ('--version' -contains $cmd -or (!$cmd -and '-v' -contains $args)) {
Push-Location $(versiondir 'scoop' 'current')
write-host "Current Scoop version:"
Invoke-Expression "git --no-pager log --oneline HEAD -n 1"
write-host ""
Pop-Location
Write-Host "Current Scoop version:"
Invoke-Expression "git -C '$(versiondir 'scoop' 'current')' --no-pager log --oneline HEAD -n 1"
Write-Host ""
Get-LocalBucket | ForEach-Object {
Push-Location (Find-BucketDirectory $_ -Root)
if(test-path '.git') {
write-host "'$_' bucket:"
Invoke-Expression "git --no-pager log --oneline HEAD -n 1"
write-host ""
$bucketLoc = Find-BucketDirectory $_ -Root
if(Test-Path (Join-Path $bucketLoc '.git')) {
Write-Host "'$_' bucket:"
Invoke-Expression "git -C '$bucketLoc' --no-pager log --oneline HEAD -n 1"
Write-Host ""
}
Pop-Location
}
}
elseif (@($null, '--help', '/?') -contains $cmd -or $args[0] -contains '-h') { exec 'help' $args }