summaryrefslogtreecommitdiff
path: root/src/Job
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-07-19 10:38:37 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2026-07-24 21:17:52 +0200
commite736b0a3ee8737b35fa79af644ca21cebafa76ef (patch)
tree9749f2cf2857f640bbe1c985804339cfd50cdda4 /src/Job
parent87724986e6e9315a1ba20211e0d51882713ba259 (diff)
JobSet expression context and dependencies
Diffstat (limited to 'src/Job')
-rw-r--r--src/Job/Types.hs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Job/Types.hs b/src/Job/Types.hs
index 6b436b5..682e056 100644
--- a/src/Job/Types.hs
+++ b/src/Job/Types.hs
@@ -1,5 +1,7 @@
module Job.Types where
+import Control.Monad.IO.Class
+
import Data.Containers.ListUtils
import Data.Kind
import Data.Text (Text)
@@ -11,6 +13,7 @@ import System.Process
import {-# SOURCE #-} Config
import Destination
+import Expr
import Repo
@@ -172,3 +175,36 @@ repoDepPath = \case
RepoDepSubtree path -> path
RepoDepCommit -> ""
RepoDepTag -> ""
+
+
+data RepoRef
+ = RepoRefTree Tree
+ | RepoRefCommit Commit
+ | RepoRefTag Commit (Tag Commit)
+
+repoRefRepo :: RepoRef -> Repo
+repoRefRepo = \case
+ RepoRefTree tree -> treeRepo tree
+ RepoRefCommit commit -> commitRepo commit
+ RepoRefTag commit _ -> commitRepo commit
+
+repoRefTree :: (MonadIO m, MonadFail m) => RepoRef -> m Tree
+repoRefTree = \case
+ RepoRefTree tree -> return tree
+ RepoRefCommit commit -> getCommitTree commit
+ RepoRefTag commit _ -> getCommitTree commit
+
+repoRefToIdPart :: MonadIO m => RepoRef -> m JobIdRepoPart
+repoRefToIdPart = \case
+ RepoRefTree tree -> return $ JobIdTree (treeSubdir tree) (treeId tree)
+ RepoRefCommit commit -> return $ JobIdCommit (commitId commit)
+ RepoRefTag commit tag -> return $ JobIdTag (commitId commit) (tagId tag)
+
+
+data JobSetContext = JobSetContext
+ { jscRepos :: [ ( Maybe RepoName, Repo ) ]
+ , jscRepoRefs :: [ ( Maybe RepoName, RepoRef ) ]
+ }
+
+instance ExprContext JobSetContext where
+ type ExprDependency JobSetContext = [ JobSetDep ]