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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- **scoop-install, scoop-update:** Unify error handling and exit codes ([#6798](https://github.com/ScoopInstaller/Scoop/issues/6798))
- **scoop-list:** Collect items before formatting to prevent column truncation ([#6800](https://github.com/ScoopInstaller/Scoop/issues/6800))
- **scoop-update:** Run missing uninstall steps and honor `--no-cache` ([#6750](https://github.com/ScoopInstaller/Scoop/issues/6750))
- **scoop-update:** Show the available version of a pinned app ([#6819](https://github.com/ScoopInstaller/Scoop/issues/6819))
- **auto-pr:** Add missing `core.ps1` dot source ([#6786](https://github.com/ScoopInstaller/Scoop/pull/6786))
- **core:** Detect the native system architecture on Arm ([#6778](https://github.com/ScoopInstaller/Scoop/issues/6778))
- **core:** End progress lines with a status marker ([#6805](https://github.com/ScoopInstaller/Scoop/issues/6805))
Expand Down
10 changes: 8 additions & 2 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,15 @@ function app_status($app, $global) {
}

$manifest = manifest $app $install_info.bucket $install_info.url
$status.pinned = (!$install_info.bucket -and $install_info.url -eq (usermanifest $app))
$latest_manifest = $manifest
if ($status.pinned) {
$scanned, $null = Find-AppBucket $app
if ($scanned) { $latest_manifest = $scanned }
}
$status.removed = (!$manifest)
if ($manifest.version) {
$status.latest_version = $manifest.version
if ($latest_manifest.version) {
$status.latest_version = $latest_manifest.version
}

$status.outdated = $false
Expand Down
1 change: 1 addition & 0 deletions libexec/scoop-list.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ $list = @($apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach
if ($is_deprecated) { 'Deprecated package' }
if ($global) { 'Global install' }
if ($install_info.hold) { 'Held package' }
if (!$install_info.bucket -and $install_info.url -eq (usermanifest $app)) { 'Pinned' }
if ($install_info.architecture -and $defaultArchitecture -ne $install_info.architecture) {
$install_info.architecture
}
Expand Down
1 change: 1 addition & 0 deletions libexec/scoop-status.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ $true, $false | ForEach-Object { # local and global apps
$info = @()
if ($status.failed) { $info += 'Install failed' }
if ($status.hold) { $info += 'Held package' }
if ($status.pinned) { $info += 'Pinned' }
if ($status.deprecated) { $info += 'Deprecated' }
if ($status.removed) { $info += 'Manifest removed' }
$item.Info = $info -join ', '
Expand Down
19 changes: 12 additions & 7 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,17 @@ if (-not ($apps -or $all)) {
$apps | ForEach-Object {
($app, $global) = $_
$status = app_status $app $global
# -f on an @version pin upgrades to the bucket HEAD; the target
# version is resolved (and warned) by update(), not guessed here
$ver = Select-CurrentVersion -AppName $app -Global:$global
$pin = install_info $app $ver $global
$is_pin = $force -and !$pin.bucket -and ($pin.url -eq (usermanifest $app))
$is_pin = $status.pinned
if ($status.installed -and ($force -or $status.outdated)) {
if (!$status.hold) {
if ($is_pin -and !$force) {
$app_key = if ($global) { "$app (global)" } else { $app }
$failed[$app_key] = "skipped: pinned to version $($status.version)"
warn "'$app' is pinned to version $($status.version), $($status.latest_version) is available.`nUse 'scoop update -f $app$(if ($global) { ' --global' })' to install the new version."
return
}
$outdated += applist $app $global
$latest = if ($is_pin) { 'HEAD (forced)' } else { $status.latest_version }
$latest = if ($force -and $is_pin) { 'HEAD (forced)' } else { $status.latest_version }
Write-Host -f yellow ("$app`: $($status.version) -> $latest{0}" -f ('', ' (global)')[$global])
} else {
warn "'$app' is held to version $($status.version)"
Expand All @@ -127,7 +129,10 @@ if (-not ($apps -or $all)) {
if ($outdated.Length -gt 1) {
Write-Host -f DarkCyan "Updating $($outdated.Length) outdated apps:"
} elseif ($outdated.Length -eq 0) {
Write-Host -f Green "Latest versions for all apps are installed! For more information try 'scoop status'"
$skipped = @($failed.Keys | Where-Object { $failed[$_] -like 'skipped:*' })
if (!$skipped.Count) {
Write-Host -f Green "Latest versions for all apps are installed! For more information try 'scoop status'"
}
} else {
Write-Host -f DarkCyan 'Updating one outdated app:'
}
Expand Down
43 changes: 43 additions & 0 deletions test/Scoop-Core.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,46 @@ Describe 'Show-DeprecatedWarning' -Tag 'Scoop' {
Should-Invoke warn -Times 2 -Exactly -ParameterFilter { $msg -like '"shim"*' }
}
}

Describe 'app_status' -Tag 'Scoop' {
BeforeAll {
. "$PSScriptRoot\..\lib\manifest.ps1" # 'install_info' 'Find-AppBucket'
. "$PSScriptRoot\..\lib\buckets.ps1" # 'Find-BucketDirectory'
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
}
BeforeEach {
Mock Test-Path { $false }
Mock get_config { $false }
}

It 'reports the bucket version of an app installed from an auto-generated manifest' {
Mock Select-CurrentVersion { '3.24.0' }
Mock install_info { [PSCustomObject]@{ url = (usermanifest 'foo') } }
Mock manifest { [PSCustomObject]@{ version = '3.24.0'; depends = @('dep') } }
Mock Find-AppBucket { [PSCustomObject]@{ version = '3.24.1'; depends = @('newdep') }, 'extras' }
Mock installed { $app -ne 'dep' }

$status = app_status 'foo' $false

$status.latest_version | Should-Be '3.24.1'
$status.outdated | Should-BeTrue
$status.pinned | Should-BeTrue
# the dependencies of the installed version, not of the newer one
$status.missing_deps | Should-BeCollection -Count 1
$status.missing_deps[0] | Should-Be 'dep'
}

It 'keeps the manifest of an app installed from a bucket' {
Mock Select-CurrentVersion { '3.24.1' }
Mock install_info { [PSCustomObject]@{ bucket = 'extras' } }
Mock manifest { [PSCustomObject]@{ version = '3.24.1' } }
Mock Find-AppBucket { [PSCustomObject]@{ version = '3.24.1' }, 'extras' }

$status = app_status 'foo' $false

$status.latest_version | Should-Be '3.24.1'
$status.outdated | Should-BeFalse
$status.pinned | Should-BeFalse
Should-Invoke -CommandName Find-AppBucket -Times 0
}
}
32 changes: 32 additions & 0 deletions test/Scoop-Install.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,35 @@ Describe 'persist_def' -Tag 'Scoop' {
$target | Should-Be 'foo'
}
}

Describe 'update_app' -Tag 'Scoop' {
BeforeAll {
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
}
BeforeEach {
Mock Select-CurrentVersion { '3.24.0' }
Mock test_running_process { $true }
Mock Write-Host {}
Mock warn {}
Mock install_info { [PSCustomObject]@{ architecture = '64bit'; url = (usermanifest 'foo') } }
Mock manifest { [PSCustomObject]@{ version = '3.24.0' } }
Mock Find-AppBucket { [PSCustomObject]@{ version = '3.24.1' }, 'extras' }
}

It 'keeps the version of an app installed from an auto-generated manifest' {
$failed = @{}
update_app 'foo' $false $false $false $false @{} $failed

Should-Invoke -CommandName warn -Times 1 -ParameterFilter { $msg -like "*'foo' (3.24.0) is already installed*" }
Should-Invoke -CommandName Find-AppBucket -Times 0
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
$failed.Count | Should-Be 0
}

It 'upgrades an app installed from an auto-generated manifest with -f' {
$failed = @{}
update_app 'foo' $false $true $true $false @{} $failed

Should-Invoke -CommandName Write-Host -Times 1 -ParameterFilter { $Object -like '*3.24.0 -> 3.24.1*' }
Should-Invoke -CommandName Find-AppBucket -Times 1
}
}