Skip to content

Commit 8b39c30

Browse files
committed
Fetch already cloned working copies and add test fixture
This adds another version of the same package fetched via git. The same working copy from _cache/git/<owner>/<repo> is re-used in both PrepareSource steps (which hopefully do not conflict) and copied onto individual _cache/<package>/<version> directories. The second package version in the git-submodule fixture _sources also uses a tag name as rev to highlight this is possible as well.
1 parent b73c836 commit 8b39c30

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

app/Foliage/GitClone.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module Foliage.GitClone (
1010
)
1111
where
1212

13-
import Control.Monad (unless)
1413
import Development.Shake
1514
import Development.Shake.Classes
1615
import Development.Shake.FilePath
@@ -46,9 +45,11 @@ addGitCloneRule cacheDir = addBuiltinRule noLint noIdentity run
4645
let path = cacheDir </> "git" </> show repo
4746

4847
alreadyCloned <- doesDirectoryExist path
49-
unless alreadyCloned $ do
50-
let url = "https://github.com/" <> show repo <> ".git"
51-
command_ [] "git" ["clone", "--recursive", url, path]
48+
if alreadyCloned
49+
then command_ [Cwd path] "git" ["fetch"]
50+
else do
51+
let url = "https://github.com/" <> show repo <> ".git"
52+
command_ [] "git" ["clone", "--recursive", url, path]
5253

5354
command_ [Cwd path] "git" ["checkout", show rev]
5455
command_ [Cwd path] "git" ["submodule", "update"]

tests/Tests.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ main = do
3535
assertFailure "entry for pkg-a-2.3.4.5 is missing"
3636
Just entry -> do
3737
entryTime entry @?= 1648534790
38-
, testCaseSteps "git submodules" $ \step ->
38+
, ---
39+
testCaseSteps "git submodules" $ \step ->
3940
inTemporaryDirectoryWithFixture "tests/fixtures/git-submodule" $ do
4041
step "Building repository"
4142
callCommand "foliage build"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
timestamp = 2023-11-03T15:53:59+00:00
1+
timestamp = 2023-11-03T17:35:22+00:00
22
github = { repo = "cardano-scaling/foliage-test-with-submodule", rev = "db5874494ee5bac3fa8fee07d5806fcec27a2f4e" }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
timestamp = 2023-11-03T15:53:59+00:00
2+
github = { repo = "cardano-scaling/foliage-test-with-submodule", rev = "1.1.0" }

0 commit comments

Comments
 (0)