diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-07-19 10:38:37 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-07-24 21:17:52 +0200 |
| commit | e736b0a3ee8737b35fa79af644ca21cebafa76ef (patch) | |
| tree | 9749f2cf2857f640bbe1c985804339cfd50cdda4 /src/Job/Types.hs | |
| parent | 87724986e6e9315a1ba20211e0d51882713ba259 (diff) | |
JobSet expression context and dependencies
Diffstat (limited to 'src/Job/Types.hs')
| -rw-r--r-- | src/Job/Types.hs | 36 |
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 ] |