Skip to content

Commit bf2688d

Browse files
zStruCatniheaven
authored andcommitted
fix(scoop-search): Remove redundant 'bucket/' in search result (ScoopInstaller#4773)
* fix remote search * add hint * tweak * docs(changelog): Update CHANGELOG Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
1 parent 92c5b1a commit bf2688d

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- **scoop-alias:** Fix alias initialization ([#4737](https://github.com/ScoopInstaller/Scoop/issues/4737))
3737
- **scoop-checkup:** Skip 'check_windows_defender' when have not admin privileges ([#4699](https://github.com/ScoopInstaller/Scoop/issues/4699))
3838
- **scoop-cleanup:** Remove apps other than current version ([#4665](https://github.com/ScoopInstaller/Scoop/issues/4665))
39+
- **scoop-search:** Remove redundant 'bucket/' in search result ([#4773](https://github.com/ScoopInstaller/Scoop/issues/4773))
3940
- **scoop-update:** Skip updating non git buckets ([#4670](https://github.com/ScoopInstaller/Scoop/issues/4670), [#4672](https://github.com/ScoopInstaller/Scoop/issues/4672))
4041

4142
### Performance Improvements

libexec/scoop-search.ps1

+12-14
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,26 @@ function search_bucket($bucket, $query) {
4848
}
4949

5050
function download_json($url) {
51-
$progressPreference = 'silentlycontinue'
52-
$result = invoke-webrequest $url -UseBasicParsing | Select-Object -exp content | convertfrom-json
53-
$progressPreference = 'continue'
51+
$ProgressPreference = 'SilentlyContinue'
52+
$result = Invoke-WebRequest $url -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json
53+
$ProgressPreference = 'Continue'
5454
$result
5555
}
5656

5757
function github_ratelimit_reached {
58-
$api_link = "https://api.github.com/rate_limit"
58+
$api_link = 'https://api.github.com/rate_limit'
5959
(download_json $api_link).rate.remaining -eq 0
6060
}
6161

6262
function search_remote($bucket, $query) {
63-
$repo = known_bucket_repo $bucket
64-
65-
$uri = [system.uri]($repo)
66-
if ($uri.absolutepath -match '/([a-zA-Z0-9]*)/([a-zA-Z0-9-]*)(.git|/)?') {
67-
$user = $matches[1]
68-
$repo_name = $matches[2]
63+
$uri = [System.Uri](known_bucket_repo $bucket)
64+
if ($uri.AbsolutePath -match '/([a-zA-Z0-9]*)/([a-zA-Z0-9-]*)(?:.git|/)?') {
65+
$user = $Matches[1]
66+
$repo_name = $Matches[2]
6967
$api_link = "https://api.github.com/repos/$user/$repo_name/git/trees/HEAD?recursive=1"
70-
$result = download_json $api_link | Select-Object -exp tree | Where-Object {
71-
$_.path -match "(^(.*$query.*).json$)"
72-
} | ForEach-Object { $matches[2] }
68+
$result = download_json $api_link | Select-Object -ExpandProperty tree |
69+
Where-Object -Value "^(?:bucket/)?(.*$query.*)\.json$" -Property Path -Match |
70+
ForEach-Object { $Matches[1] }
7371
}
7472

7573
$result
@@ -90,7 +88,7 @@ function search_remotes($query) {
9088
}
9189

9290
$results | ForEach-Object {
93-
"'$($_.bucket)' bucket:"
91+
"'$($_.bucket)' bucket (install using 'scoop install $($_.bucket)/<app>'):"
9492
$_.results | ForEach-Object { " $_" }
9593
""
9694
}

0 commit comments

Comments
 (0)