@@ -63,61 +63,58 @@ function update_scoop() {
63
63
# check for git
64
64
if (! (Test-CommandAvailable git)) { abort " Scoop uses Git to update itself. Run 'scoop install git' and try again." }
65
65
66
- write-host " Updating Scoop..."
66
+ Write-Host " Updating Scoop..."
67
67
$last_update = $ (last_scoop_update)
68
68
if ($null -eq $last_update ) {$last_update = [System.DateTime ]::Now}
69
69
$last_update = $last_update.ToString (' s' )
70
70
$show_update_log = get_config ' show_update_log' $true
71
71
$currentdir = fullpath $ (versiondir ' scoop' ' current' )
72
- if (! (test-path " $currentdir \.git" )) {
72
+ if (! (Test-Path " $currentdir \.git" )) {
73
73
$newdir = fullpath $ (versiondir ' scoop' ' new' )
74
74
75
75
# get git scoop
76
76
git_clone - q $configRepo -- branch $configBranch -- single- branch " `" $newdir `" "
77
77
78
78
# check if scoop was successful downloaded
79
- if (! (test-path " $newdir " )) {
79
+ if (! (Test-Path " $newdir " )) {
80
80
abort ' Scoop update failed.'
81
81
}
82
82
83
83
# replace non-git scoop with the git version
84
84
Remove-Item - r - force $currentdir - ea stop
85
85
Move-Item $newdir $currentdir
86
86
} 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"
92
90
93
91
$isRepoChanged = ! ($currentRepo -match $configRepo )
94
92
$isBranchChanged = ! ($currentBranch -match " \*\s+$configBranch " )
95
93
96
94
# Change remote url if the repo is changed
97
95
if ($isRepoChanged ) {
98
- Invoke-Expression " git config remote.origin.url '$configRepo '"
96
+ Invoke-Expression " git -C ' $currentdir ' config remote.origin.url '$configRepo '"
99
97
}
100
98
101
99
# Fetch and reset local repo if the repo or the branch is changed
102
100
if ($isRepoChanged -or $isBranchChanged ) {
103
101
# 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/*'"
105
103
# 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
107
105
# 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
109
107
# reset branch HEAD
110
- Invoke-Expression " git reset --hard origin/$configBranch -q"
108
+ Invoke-Expression " git -C ' $currentdir ' reset --hard origin/$configBranch -q"
111
109
} else {
112
- git_pull - q
110
+ git_cmd - C " `" $currentdir `" " pull - q
113
111
}
114
112
115
113
$res = $lastexitcode
116
114
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'"
118
116
}
119
117
120
- Pop-Location
121
118
if ($res -ne 0 ) {
122
119
abort ' Update failed.'
123
120
}
@@ -150,13 +147,11 @@ function update_scoop() {
150
147
continue
151
148
}
152
149
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
156
152
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'"
158
154
}
159
- Pop-Location
160
155
}
161
156
162
157
set_config lastupdate ([System.DateTime ]::Now.ToString(' o' )) | Out-Null
@@ -196,7 +191,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
196
191
return
197
192
}
198
193
199
- write-host " Updating '$app ' ($old_version -> $version )"
194
+ Write-Host " Updating '$app ' ($old_version -> $version )"
200
195
201
196
# region Workaround
202
197
# 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
217
212
218
213
if (! $ok ) {
219
214
error $err
220
- if (test-path $source ) {
215
+ if (Test-Path $source ) {
221
216
# rm cached file
222
217
Remove-Item - force $source
223
218
}
@@ -244,7 +239,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
244
239
}
245
240
# endregion Workaround for #2952
246
241
247
- write-host " Uninstalling '$app ' ($old_version )"
242
+ Write-Host " Uninstalling '$app ' ($old_version )"
248
243
run_uninstaller $old_manifest $architecture $dir
249
244
rm_shims $old_manifest $global $architecture
250
245
env_rm_path $old_manifest $dir $global $architecture
@@ -319,7 +314,7 @@ if (-not ($apps -or $all)) {
319
314
if ($status.installed -and ($force -or $status.outdated )) {
320
315
if (! $status.hold ) {
321
316
$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 ])
323
318
} else {
324
319
warn " '$app ' is held to version $ ( $status.version ) "
325
320
}
@@ -338,11 +333,11 @@ if (-not ($apps -or $all)) {
338
333
warn " To disable this warning, run 'scoop config aria2-warning-enabled false'."
339
334
}
340
335
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:"
342
337
} 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'"
344
339
} else {
345
- write-host -f DarkCyan " Updating one outdated app:"
340
+ Write-Host -f DarkCyan " Updating one outdated app:"
346
341
}
347
342
}
348
343
0 commit comments