summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-03-18 19:24:16 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2025-03-18 19:24:16 +0100
commitcd1bc22732eb713a298c769d6f7bc02830d00296 (patch)
tree401db674140312850330ffba43cfdd07c87908a1
parent40015c9ffb6863b7df68e950ee24b75024de6042 (diff)
Tread repo paths from job file as relative to that file
-rw-r--r--src/Main.hs24
1 files 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