From f449ef32e31e10b9412e932f0181ccfa4314e728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 8 Nov 2025 22:24:27 +0100 Subject: Allow repo declaration without giving path --- src/Main.hs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/Main.hs') 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 -- cgit v1.2.3