Skip to content

Commit e06e13d

Browse files
committed
Add user prefix filter to query
1 parent 56bbac7 commit e06e13d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

unison-cli/src/Unison/CommandLine/Completion.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ completeShareBranchHelper authHTTPClient query = do
476476
pure $
477477
Monoid.whenM (Text.isPrefixOf branchOrContributorPrefix "releases") [handle <> "/" <> proj <> "/releases/"]
478478
<> results
479+
[handle, proj, "releases", ""] -> do
480+
searchProjectReleases authHTTPClient handle proj ""
481+
<&> (handle <> "/" <> proj <> "/releases/latest" :)
479482
[handle, proj, "releases", branch]
480483
| Text.isPrefixOf branch "latest" -> pure [handle <> "/" <> proj <> "/releases/latest"]
481484
| otherwise -> do
@@ -496,14 +499,14 @@ searchProjectBranches ::
496499
m [Text]
497500
searchProjectBranches (AuthenticatedHttpClient httpManager) handle proj contributor query = do
498501
fromMaybe [] <$> runMaybeT do
499-
let searchKind = case contributor of
500-
Just {} -> "contributor"
501-
Nothing -> "core"
502+
let (searchKind, contributorFilter) = case contributor of
503+
Just contributor -> ("contributor", "&contributor-handle=" <> contributor)
504+
Nothing -> ("core", "")
502505
let cleanedHandle = Text.dropWhile (== '@') handle
503506
let uri =
504507
(Share.codeserverToURI Codeserver.defaultCodeserver)
505508
{ URI.uriPath = "/users/" <> Text.unpack cleanedHandle <> "/projects/" <> Text.unpack proj <> "/branches",
506-
URI.uriQuery = Text.unpack $ "?name-prefix=" <> query <> "&kind=" <> searchKind
509+
URI.uriQuery = Text.unpack $ "?name-prefix=" <> query <> "&kind=" <> searchKind <> contributorFilter
507510
}
508511
Debug.debugM Debug.Temp "searchProjectBranches: uri: " (Text.pack $ show uri)
509512
req <- MaybeT $ pure (HTTP.requestFromURI uri)

0 commit comments

Comments
 (0)