Skip to content

GH-612: core search can exact-match Platform#ID too. #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2020
Merged
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
6 changes: 5 additions & 1 deletion commands/core/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func match(line, searchArgs string) bool {
return strings.Contains(strings.ToLower(line), strings.ToLower(searchArgs))
}

func exactMatch(line, searchArgs string) bool {
return strings.Compare(strings.ToLower(line), strings.ToLower(searchArgs)) == 0
}

// PlatformSearch FIXMEDOC
func PlatformSearch(instanceID int32, searchArgs string, allVersions bool) (*rpc.PlatformSearchResp, error) {
pm := commands.GetPackageManager(instanceID)
Expand All @@ -55,7 +59,7 @@ func PlatformSearch(instanceID int32, searchArgs string, allVersions bool) (*rpc
}

// platform has a valid release, check if it matches the search arguments
if match(platform.Name, searchArgs) || match(platform.Architecture, searchArgs) {
if match(platform.Name, searchArgs) || match(platform.Architecture, searchArgs) || exactMatch(platform.String(), searchArgs) {
if allVersions {
res = append(res, platform.GetAllReleases()...)
} else {
Expand Down