From 52dca5dc0e60d4d84aa5ecf280a45b24f1111dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 15 Mar 2025 15:29:01 +0100 Subject: Checkout referenced repos when preparing job --- src/Job.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/Job.hs') diff --git a/src/Job.hs b/src/Job.hs index 1d30489..820f5e5 100644 --- a/src/Job.hs +++ b/src/Job.hs @@ -286,12 +286,23 @@ prepareJob dir mbCommit job inner = do jdirCommit <- case mbCommit of Just commit -> do tree <- getCommitTree commit - checkoutAt tree checkoutPath + forM_ (jobContainingCheckout job) $ \(JobCheckout mbsub dest) -> do + subtree <- maybe return (getSubtree mbCommit) mbsub $ tree + checkoutAt subtree $ checkoutPath fromMaybe "" dest return $ showTreeId (treeId tree) stringJobName (jobName job) Nothing -> do + when (not $ null $ jobContainingCheckout job) $ do + fail $ "no containing repository, can't do checkout" return $ stringJobName (jobName job) - let jdir = dir "jobs" jdirCommit + jdirOther <- forM (jobOtherCheckout job) $ \( EvaluatedJobRepo repo, revision, JobCheckout mbsub dest ) -> do + commit <- readCommit repo $ fromMaybe "HEAD" revision + tree <- getCommitTree commit + subtree <- maybe return (getSubtree (Just commit)) mbsub $ tree + checkoutAt subtree $ checkoutPath fromMaybe "" dest + return $ showTreeId (treeId tree) + + let jdir = dir "jobs" jdirCommit joinPath jdirOther liftIO $ createDirectoryIfMissing True jdir inner checkoutPath jdir -- cgit v1.2.3