From 3bb1c548e2696abd3f7dc2d7b9fbc27ceb490c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Fri, 14 Mar 2025 21:18:17 +0100 Subject: Evaluate repo definitions --- src/Main.hs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs index f86bd77..826a96d 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -184,18 +184,24 @@ runSomeCommand ciConfigPath ciOptions (SC tproxy) args = do let cmd = commandInit tproxy (fcoSpecific opts) cmdargs let CommandExec exec = commandExec cmd - namedRepos <- forM (optRepo ciOptions) $ \decl -> do - openRepo (repoPath decl) >>= \case - Just repo -> return ( Just (repoName decl), repo ) - Nothing -> do - hPutStrLn stderr $ "Failed to open repo `" <> showRepoName (repoName decl) <> "' at " <> repoPath decl - exitFailure + ciContainingRepo <- maybe (return Nothing) (openRepo . takeDirectory) ciConfigPath + + let openDeclaredRepo decl = do + openRepo (repoPath decl) >>= \case + Just repo -> return ( repoName decl, repo ) + Nothing -> do + hPutStrLn stderr $ "Failed to open repo `" <> showRepoName (repoName decl) <> "' at " <> repoPath decl + exitFailure + + cmdlineRepos <- forM (optRepo ciOptions) openDeclaredRepo + configRepos <- case ciConfig of + Right config -> forM (configRepos config) $ \decl -> do + case lookup (repoName decl) cmdlineRepos of + Just repo -> return ( repoName decl, repo ) + Nothing -> openDeclaredRepo decl + Left _ -> return [] - defaultRepo <- maybe (return Nothing) (openRepo . takeDirectory) ciConfigPath - let ciRepos = concat - [ maybe [] (\r -> [ ( Nothing, r ) ]) defaultRepo - , namedRepos - ] + let ciOtherRepos = configRepos ++ cmdlineRepos ciTerminalOutput <- initTerminalOutput flip runReaderT CommandInput {..} exec -- cgit v1.2.3