Skip to content

Commit dc6a42b

Browse files
authored
Filter by prefix on no exact match (#442)
* Filter by prefix on no exact match * Clarify comment
1 parent d9593c7 commit dc6a42b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Niv/Cli.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ filterPackages :: Sources -> Maybe PackagePattern -> Sources
386386
filterPackages (unSources -> sources) mPat = Sources $ case mPat of
387387
-- no pattern: return all packages
388388
Nothing -> sources
389-
-- pattern (filter) provided: match exact
389+
-- pattern (filter) provided: return an exact match; if no exact match, match by prefix
390390
Just (PackagePattern pat) -> case HMS.lookup (PackageName pat) sources of
391391
Just exact -> HMS.singleton (PackageName pat) exact
392392
Nothing ->
393-
HMS.filterWithKey (\k _ -> unPackageName k == pat) sources
393+
HMS.filterWithKey (\k _ -> pat `T.isPrefixOf` (unPackageName k)) sources
394394

395395
parseCmdUpdate :: Opts.ParserInfo (NIO ())
396396
parseCmdUpdate =

0 commit comments

Comments
 (0)