summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-11-08 22:24:27 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2025-11-08 22:24:27 +0100
commitf449ef32e31e10b9412e932f0181ccfa4314e728 (patch)
tree3322d63a909615cb18874796bb0adcb93b21d66d /src/Main.hs
parentd8354b8f1b2bbb6d911070ca9822c7e4fbd88bca (diff)
Allow repo declaration without giving path
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 83b0ab3..91d3acd 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -65,7 +65,7 @@ options =
case span (/= ':') value of
( repo, ':' : path ) -> return opts
{ optCommon = (optCommon opts)
- { optRepo = DeclaredRepo (RepoName $ T.pack repo) path : optRepo (optCommon opts)
+ { optRepo = ( RepoName $ T.pack repo, path ) : optRepo (optCommon opts)
}
}
_ -> throwError $ "--repo: invalid value ‘" <> value <> "’"
@@ -243,13 +243,13 @@ runSomeCommand rootPath gopts (SC tproxy) args = do
JobRootRepo repo -> return (Just repo)
JobRootConfig _ -> openRepo $ takeDirectory ciRootPath
- let openDeclaredRepo dir decl = do
- let path = dir </> repoPath decl
+ let openDeclaredRepo dir ( name, dpath ) = do
+ let path = dir </> dpath
openRepo path >>= \case
- Just repo -> return ( repoName decl, repo )
+ Just repo -> return ( name, repo )
Nothing -> do
absPath <- makeAbsolute path
- hPutStrLn stderr $ "Failed to open repo ‘" <> showRepoName (repoName decl) <> "’ at " <> repoPath decl <> " (" <> absPath <> ")"
+ hPutStrLn stderr $ "Failed to open repo ‘" <> showRepoName name <> "’ at " <> dpath <> " (" <> absPath <> ")"
exitFailure
cmdlineRepos <- forM (optRepo ciOptions) (openDeclaredRepo "")
@@ -258,7 +258,14 @@ runSomeCommand rootPath gopts (SC tproxy) args = do
forM (configRepos config) $ \decl -> do
case lookup (repoName decl) cmdlineRepos of
Just repo -> return ( repoName decl, repo )
- Nothing -> openDeclaredRepo (takeDirectory ciRootPath) decl
+ Nothing
+ | Just path <- repoPath decl
+ -> openDeclaredRepo (takeDirectory ciRootPath) ( repoName decl, path )
+
+ | otherwise
+ -> do
+ hPutStrLn stderr $ "No path defined for repo ‘" <> showRepoName (repoName decl) <> "’"
+ exitFailure
_ -> return []
let ciOtherRepos = configRepos ++ cmdlineRepos