From ff3122f0a82f2c0ba3593282f43c911ac521ca12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 27 Nov 2025 21:54:20 +0100 Subject: Do not use checkouts with explicit revision in job ID --- src/Eval.hs | 15 +++++++++++---- test/asset/run/many_repos.yaml | 26 ++++++++++++++++++++++++++ test/script/run.et | 20 ++++++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/Eval.hs b/src/Eval.hs index 71c9b9f..572dad2 100644 --- a/src/Eval.hs +++ b/src/Eval.hs @@ -114,7 +114,10 @@ evalJob revisionOverrides dset decl = do Just dest -> return $ dpublish { jpDestination = dest } Nothing -> throwError $ OtherEvalError $ "no url defined for destination ‘" <> textDestinationName (jpDestination dpublish) <> "’" - let otherRepoIds = map (\( repo, ( subtree, tree )) -> JobIdTree (fst <$> repo) subtree (treeId tree)) otherRepoTrees + let otherRepoIds = flip mapMaybe otherRepoTrees $ \case + ( repo, ( subtree, tree )) -> do + guard $ maybe True (isNothing . snd) repo -- use only checkouts without explicit revision in job id + Just $ JobIdTree (fst <$> repo) subtree (treeId tree) return ( Job { jobId = JobId $ reverse $ reverse otherRepoIds ++ JobIdName (jobId decl) : eiCurrentIdRev @@ -166,9 +169,13 @@ canonicalJobName (r : rs) config mbDefaultRepo = do Just djob -> do otherRepos <- collectOtherRepos dset djob ( overrides, rs' ) <- (\f -> foldM f ( [], rs ) otherRepos) $ - \( overrides, crs ) ( mbrepo, path ) -> do - ( tree, crs' ) <- readTreeFromIdRef crs path =<< evalRepo (fst <$> mbrepo) - return ( ( fst <$> mbrepo, tree ) : overrides, crs' ) + \( overrides, crs ) ( mbrepo, path ) -> if + | Just ( _, Just _ ) <- mbrepo -> do + -- use only checkouts without explicit revision in job id + return ( overrides, crs ) + | otherwise -> do + ( tree, crs' ) <- readTreeFromIdRef crs path =<< evalRepo (fst <$> mbrepo) + return ( ( fst <$> mbrepo, tree ) : overrides, crs' ) case rs' of (r' : _) -> throwError $ OtherEvalError $ "unexpected job ref part ‘" <> r' <> "’" _ -> return () diff --git a/test/asset/run/many_repos.yaml b/test/asset/run/many_repos.yaml index 63f8fa2..5910526 100644 --- a/test/asset/run/many_repos.yaml +++ b/test/asset/run/many_repos.yaml @@ -21,3 +21,29 @@ job first: artifact out: path: some_file + +job first_manual_revision: + checkout: + - repo: r1 + dest: d1 + - repo: r1 + dest: d1b + revision: tag1 + - repo: r2 + dest: d2b + revision: tag1 + - repo: r4 + dest: d4b + - repo: r3 + dest: d3 + revision: tag1 + - repo: r2 + dest: d2 + - repo: r4 + dest: d4 + + shell: + - touch some_file + + artifact out: + path: some_file diff --git a/test/script/run.et b/test/script/run.et index 9fbfd13..c148fd9 100644 --- a/test/script/run.et +++ b/test/script/run.et @@ -419,6 +419,10 @@ test RunWithManyRepos: touch dir_r1/file_r1 git -C dir_r1 add file_r1 git -C dir_r1 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r1' + git -C dir_r1 -c user.name=test -c user.email=test tag tag1 -m tag1 + touch dir_r1/file2_r1 + git -C dir_r1 add file2_r1 + git -C dir_r1 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r1' git -C dir_r1 rev-parse HEAD git -C dir_r1 rev-parse HEAD^{tree} @@ -428,12 +432,20 @@ test RunWithManyRepos: touch dir_r2/file_r2 git -C dir_r2 add file_r2 git -C dir_r2 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r2' + git -C dir_r2 -c user.name=test -c user.email=test tag tag1 -m tag1 + touch dir_r2/file2_r2 + git -C dir_r2 add file2_r2 + git -C dir_r2 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r2' git -C dir_r2 rev-parse HEAD git -C dir_r2 rev-parse HEAD^{tree} mkdir -p dir_r3 git -C dir_r3 -c init.defaultBranch=master init -q git -C dir_r3 -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + touch dir_r3/file2_r3 + git -C dir_r3 add file2_r3 + git -C dir_r3 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r3' + git -C dir_r3 -c user.name=test -c user.email=test tag tag1 -m tag1 touch dir_r3/file_r3 git -C dir_r3 add file_r3 git -C dir_r3 -c user.name=test -c user.email=test commit -q --allow-empty -m 'commit r3' @@ -467,3 +479,11 @@ test RunWithManyRepos: local: spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "./main", "run", "--rerun-all", "$mc.first.$r1c.$r2t.$r3c.$r4t" ] expect_success from p of "$mt.first.$r1t.$r2t.$r3t.$r4t" + + local: + spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "./main", "run", "--rerun-all", "first_manual_revision" ] + expect_success from p of "$mt.first_manual_revision.$r1t.$r2t.$r4t" + + local: + spawn on n as p args [ "--storage=minici", "--repo=r1:./dir_r1", "--repo=r3:./dir_r3", "--repo=r4:./dir_r4", "--repo=r2:./dir_r2", "./main", "run", "--rerun-all", "$mc.first_manual_revision.$r1c.$r2t.$r4t" ] + expect_success from p of "$mt.first_manual_revision.$r1t.$r2t.$r4t" -- cgit v1.2.3