Skip to content

Commit

Permalink
fuzzy repo search
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavsteindler committed Dec 12, 2024
1 parent 506feae commit 0ee9684
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions pkg/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,23 +599,22 @@ func (c *Catalog) ListRepositories(ctx context.Context, limit int, prefix, after
for it.Next() {
record := it.Value()

if !strings.HasPrefix(string(record.RepositoryID), prefix) {
break
}
if strings.Contains(string(record.RepositoryID), prefix) {

if record.RepositoryID == afterRepositoryID {
continue
}
repos = append(repos, &Repository{
Name: record.RepositoryID.String(),
StorageNamespace: record.StorageNamespace.String(),
DefaultBranch: record.DefaultBranchID.String(),
CreationDate: record.CreationDate,
ReadOnly: record.ReadOnly,
})
// collect limit +1 to return limit and has more
if len(repos) >= limit+1 {
break
if record.RepositoryID == afterRepositoryID {
continue
}
repos = append(repos, &Repository{
Name: record.RepositoryID.String(),
StorageNamespace: record.StorageNamespace.String(),
DefaultBranch: record.DefaultBranchID.String(),
CreationDate: record.CreationDate,
ReadOnly: record.ReadOnly,
})
// collect limit +1 to return limit and has more

Check failure on line 614 in pkg/catalog/catalog.go

View workflow job for this annotation

GitHub Actions / Run Linters and Checkers

unnecessary leading newline (whitespace)
if len(repos) >= limit+1 {
break
}
}
}
if err := it.Err(); err != nil {
Expand Down

0 comments on commit 0ee9684

Please sign in to comment.