From cd1bc22732eb713a298c769d6f7bc02830d00296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 18 Mar 2025 19:24:16 +0100 Subject: Tread repo paths from job file as relative to that file --- src/Main.hs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 826a96d..b98c66a 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -10,6 +10,7 @@ import Data.Proxy import Data.Text qualified as T import System.Console.GetOpt +import System.Directory import System.Environment import System.Exit import System.FilePath @@ -186,20 +187,23 @@ runSomeCommand ciConfigPath ciOptions (SC tproxy) args = do ciContainingRepo <- maybe (return Nothing) (openRepo . takeDirectory) ciConfigPath - let openDeclaredRepo decl = do - openRepo (repoPath decl) >>= \case + let openDeclaredRepo dir decl = do + let path = dir repoPath decl + openRepo path >>= \case Just repo -> return ( repoName decl, repo ) Nothing -> do - hPutStrLn stderr $ "Failed to open repo `" <> showRepoName (repoName decl) <> "' at " <> repoPath decl + absPath <- makeAbsolute path + hPutStrLn stderr $ "Failed to open repo `" <> showRepoName (repoName decl) <> "' at " <> repoPath decl <> " (" <> absPath <> ")" 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 [] + cmdlineRepos <- forM (optRepo ciOptions) (openDeclaredRepo "") + configRepos <- case ( ciConfigPath, ciConfig ) of + ( Just path, Right config ) -> + forM (configRepos config) $ \decl -> do + case lookup (repoName decl) cmdlineRepos of + Just repo -> return ( repoName decl, repo ) + Nothing -> openDeclaredRepo (takeDirectory path) decl + _ -> return [] let ciOtherRepos = configRepos ++ cmdlineRepos -- cgit v1.2.3