Skip to content

Commit

Permalink
Fetch already cloned working copies and add test fixture
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ch1bo committed Nov 13, 2023
1 parent 77d2454 commit 7cd94c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions app/Foliage/GitClone.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Foliage.GitClone (
)
where

import Control.Monad (unless)
import Development.Shake
import Development.Shake.Classes
import Development.Shake.FilePath
Expand Down Expand Up @@ -46,9 +45,11 @@ addGitCloneRule cacheDir = addBuiltinRule noLint noIdentity run
let path = cacheDir </> "git" </> show repo

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

command_ [Cwd path] "git" ["checkout", show rev]
command_ [Cwd path] "git" ["submodule", "update"]
Expand Down
3 changes: 2 additions & 1 deletion tests/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ main = do
assertFailure "entry for pkg-a-2.3.4.5 is missing"
Just entry -> do
entryTime entry @?= 1648534790
, testCaseSteps "git submodules" $ \step ->
, ---
testCaseSteps "git submodules" $ \step ->
inTemporaryDirectoryWithFixture "tests/fixtures/git-submodule" $ do
step "Building repository"
callCommand "foliage build"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
timestamp = 2023-11-03T15:53:59+00:00
timestamp = 2023-11-03T17:35:22+00:00
github = { repo = "cardano-scaling/foliage-test-with-submodule", rev = "db5874494ee5bac3fa8fee07d5806fcec27a2f4e" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
timestamp = 2023-11-03T15:53:59+00:00
github = { repo = "cardano-scaling/foliage-test-with-submodule", rev = "1.1.0" }

0 comments on commit 7cd94c9

Please sign in to comment.