mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-12-11 10:35:44 +00:00
fix(scoop-search): Remove redundant 'bucket/' in search result (#4773)
* fix remote search * add hint * tweak * docs(changelog): Update CHANGELOG Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
- **scoop-alias:** Fix alias initialization ([#4737](https://github.com/ScoopInstaller/Scoop/issues/4737))
|
||||
- **scoop-checkup:** Skip 'check_windows_defender' when have not admin privileges ([#4699](https://github.com/ScoopInstaller/Scoop/issues/4699))
|
||||
- **scoop-cleanup:** Remove apps other than current version ([#4665](https://github.com/ScoopInstaller/Scoop/issues/4665))
|
||||
- **scoop-search:** Remove redundant 'bucket/' in search result ([#4773](https://github.com/ScoopInstaller/Scoop/issues/4773))
|
||||
- **scoop-update:** Skip updating non git buckets ([#4670](https://github.com/ScoopInstaller/Scoop/issues/4670), [#4672](https://github.com/ScoopInstaller/Scoop/issues/4672))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
@@ -48,28 +48,26 @@ function search_bucket($bucket, $query) {
|
||||
}
|
||||
|
||||
function download_json($url) {
|
||||
$progressPreference = 'silentlycontinue'
|
||||
$result = invoke-webrequest $url -UseBasicParsing | Select-Object -exp content | convertfrom-json
|
||||
$progressPreference = 'continue'
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$result = Invoke-WebRequest $url -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json
|
||||
$ProgressPreference = 'Continue'
|
||||
$result
|
||||
}
|
||||
|
||||
function github_ratelimit_reached {
|
||||
$api_link = "https://api.github.com/rate_limit"
|
||||
$api_link = 'https://api.github.com/rate_limit'
|
||||
(download_json $api_link).rate.remaining -eq 0
|
||||
}
|
||||
|
||||
function search_remote($bucket, $query) {
|
||||
$repo = known_bucket_repo $bucket
|
||||
|
||||
$uri = [system.uri]($repo)
|
||||
if ($uri.absolutepath -match '/([a-zA-Z0-9]*)/([a-zA-Z0-9-]*)(.git|/)?') {
|
||||
$user = $matches[1]
|
||||
$repo_name = $matches[2]
|
||||
$uri = [System.Uri](known_bucket_repo $bucket)
|
||||
if ($uri.AbsolutePath -match '/([a-zA-Z0-9]*)/([a-zA-Z0-9-]*)(?:.git|/)?') {
|
||||
$user = $Matches[1]
|
||||
$repo_name = $Matches[2]
|
||||
$api_link = "https://api.github.com/repos/$user/$repo_name/git/trees/HEAD?recursive=1"
|
||||
$result = download_json $api_link | Select-Object -exp tree | Where-Object {
|
||||
$_.path -match "(^(.*$query.*).json$)"
|
||||
} | ForEach-Object { $matches[2] }
|
||||
$result = download_json $api_link | Select-Object -ExpandProperty tree |
|
||||
Where-Object -Value "^(?:bucket/)?(.*$query.*)\.json$" -Property Path -Match |
|
||||
ForEach-Object { $Matches[1] }
|
||||
}
|
||||
|
||||
$result
|
||||
@@ -90,7 +88,7 @@ function search_remotes($query) {
|
||||
}
|
||||
|
||||
$results | ForEach-Object {
|
||||
"'$($_.bucket)' bucket:"
|
||||
"'$($_.bucket)' bucket (install using 'scoop install $($_.bucket)/<app>'):"
|
||||
$_.results | ForEach-Object { " $_" }
|
||||
""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user