@@ -63,61 +63,58 @@ function update_scoop() {
6363 # check for git
6464 if (! (Test-CommandAvailable git)) { abort " Scoop uses Git to update itself. Run 'scoop install git' and try again." }
6565
66- write-host " Updating Scoop..."
66+ Write-Host " Updating Scoop..."
6767 $last_update = $ (last_scoop_update)
6868 if ($null -eq $last_update ) {$last_update = [System.DateTime ]::Now}
6969 $last_update = $last_update.ToString (' s' )
7070 $show_update_log = get_config ' show_update_log' $true
7171 $currentdir = fullpath $ (versiondir ' scoop' ' current' )
72- if (! (test-path " $currentdir \.git" )) {
72+ if (! (Test-Path " $currentdir \.git" )) {
7373 $newdir = fullpath $ (versiondir ' scoop' ' new' )
7474
7575 # get git scoop
7676 git_clone - q $configRepo -- branch $configBranch -- single- branch " `" $newdir `" "
7777
7878 # check if scoop was successful downloaded
79- if (! (test-path " $newdir " )) {
79+ if (! (Test-Path " $newdir " )) {
8080 abort ' Scoop update failed.'
8181 }
8282
8383 # replace non-git scoop with the git version
8484 Remove-Item - r - force $currentdir - ea stop
8585 Move-Item $newdir $currentdir
8686 } else {
87- Push-Location $currentdir
88-
89- $previousCommit = Invoke-Expression ' git rev-parse HEAD'
90- $currentRepo = Invoke-Expression " git config remote.origin.url"
91- $currentBranch = Invoke-Expression " git branch"
87+ $previousCommit = Invoke-Expression " git -C '$currentdir ' rev-parse HEAD"
88+ $currentRepo = Invoke-Expression " git -C '$currentdir ' config remote.origin.url"
89+ $currentBranch = Invoke-Expression " git -C '$currentdir ' branch"
9290
9391 $isRepoChanged = ! ($currentRepo -match $configRepo )
9492 $isBranchChanged = ! ($currentBranch -match " \*\s+$configBranch " )
9593
9694 # Change remote url if the repo is changed
9795 if ($isRepoChanged ) {
98- Invoke-Expression " git config remote.origin.url '$configRepo '"
96+ Invoke-Expression " git -C ' $currentdir ' config remote.origin.url '$configRepo '"
9997 }
10098
10199 # Fetch and reset local repo if the repo or the branch is changed
102100 if ($isRepoChanged -or $isBranchChanged ) {
103101 # Reset git fetch refs, so that it can fetch all branches (GH-3368)
104- Invoke-Expression " git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'"
102+ Invoke-Expression " git -C ' $currentdir ' config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'"
105103 # fetch remote branch
106- git_fetch -- force origin " refs/heads/`" $configBranch `" :refs/remotes/origin/$configBranch " - q
104+ git_cmd - C " `" $currentdir `" " fetch -- force origin " refs/heads/`" $configBranch `" :refs/remotes/origin/$configBranch " - q
107105 # checkout and track the branch
108- git_checkout - B $configBranch - t origin/ $configBranch - q
106+ git_cmd - C " `" $currentdir `" " checkout - B $configBranch - t origin/ $configBranch - q
109107 # reset branch HEAD
110- Invoke-Expression " git reset --hard origin/$configBranch -q"
108+ Invoke-Expression " git -C ' $currentdir ' reset --hard origin/$configBranch -q"
111109 } else {
112- git_pull - q
110+ git_cmd - C " `" $currentdir `" " pull - q
113111 }
114112
115113 $res = $lastexitcode
116114 if ($show_update_log ) {
117- Invoke-Expression " git --no-pager log --no-decorate --grep='^chore' --invert-grep --format='tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset' '$previousCommit ..HEAD'"
115+ Invoke-Expression " git -C ' $currentdir ' - -no-pager log --no-decorate --grep='^chore' --invert-grep --format='tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset' '$previousCommit ..HEAD'"
118116 }
119117
120- Pop-Location
121118 if ($res -ne 0 ) {
122119 abort ' Update failed.'
123120 }
@@ -150,13 +147,11 @@ function update_scoop() {
150147 continue
151148 }
152149
153- Push-Location $bucketLoc
154- $previousCommit = (Invoke-Expression ' git rev-parse HEAD' )
155- git_pull - q
150+ $previousCommit = (Invoke-Expression " git -C '$bucketLoc ' rev-parse HEAD" )
151+ git_cmd - C " `" $bucketLoc `" " pull - q
156152 if ($show_update_log ) {
157- Invoke-Expression " git --no-pager log --no-decorate --grep='^chore' --invert-grep --format='tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset' '$previousCommit ..HEAD'"
153+ Invoke-Expression " git -C ' $bucketLoc ' - -no-pager log --no-decorate --grep='^chore' --invert-grep --format='tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset' '$previousCommit ..HEAD'"
158154 }
159- Pop-Location
160155 }
161156
162157 set_config lastupdate ([System.DateTime ]::Now.ToString(' o' )) | Out-Null
@@ -196,7 +191,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
196191 return
197192 }
198193
199- write-host " Updating '$app ' ($old_version -> $version )"
194+ Write-Host " Updating '$app ' ($old_version -> $version )"
200195
201196 # region Workaround
202197 # Workaround for https://github.com/ScoopInstaller/Scoop/issues/2220 until install is refactored
@@ -217,7 +212,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
217212
218213 if (! $ok ) {
219214 error $err
220- if (test-path $source ) {
215+ if (Test-Path $source ) {
221216 # rm cached file
222217 Remove-Item - force $source
223218 }
@@ -244,7 +239,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
244239 }
245240 # endregion Workaround for #2952
246241
247- write-host " Uninstalling '$app ' ($old_version )"
242+ Write-Host " Uninstalling '$app ' ($old_version )"
248243 run_uninstaller $old_manifest $architecture $dir
249244 rm_shims $old_manifest $global $architecture
250245 env_rm_path $old_manifest $dir $global $architecture
@@ -319,7 +314,7 @@ if (-not ($apps -or $all)) {
319314 if ($status.installed -and ($force -or $status.outdated )) {
320315 if (! $status.hold ) {
321316 $outdated += applist $app $global
322- write-host -f yellow (" $app `: $ ( $status.version ) -> $ ( $status.latest_version ) {0}" -f (' ' , ' (global)' )[$global ])
317+ Write-Host -f yellow (" $app `: $ ( $status.version ) -> $ ( $status.latest_version ) {0}" -f (' ' , ' (global)' )[$global ])
323318 } else {
324319 warn " '$app ' is held to version $ ( $status.version ) "
325320 }
@@ -338,11 +333,11 @@ if (-not ($apps -or $all)) {
338333 warn " To disable this warning, run 'scoop config aria2-warning-enabled false'."
339334 }
340335 if ($outdated.Length -gt 1 ) {
341- write-host -f DarkCyan " Updating $ ( $outdated.Length ) outdated apps:"
336+ Write-Host -f DarkCyan " Updating $ ( $outdated.Length ) outdated apps:"
342337 } elseif ($outdated.Length -eq 0 ) {
343- write-host -f Green " Latest versions for all apps are installed! For more information try 'scoop status'"
338+ Write-Host -f Green " Latest versions for all apps are installed! For more information try 'scoop status'"
344339 } else {
345- write-host -f DarkCyan " Updating one outdated app:"
340+ Write-Host -f DarkCyan " Updating one outdated app:"
346341 }
347342 }
348343
0 commit comments