Skip to content

Commit

Permalink
Update git package submodules after clone and reset
Browse files Browse the repository at this point in the history
For packages identified by git locations, this changes the logic to:
1. clone the repo
2. reset --hard to a specific commit
3. update submodules (recursively)
  • Loading branch information
tclem committed Sep 21, 2018
1 parent 7015fda commit 8bda49d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Bug fixes:
* Fix `subdirs` for git repos in `extra-deps` to match whole directory names.
Also fixes for `subdirs: .`. See
[#4292](https://github.com/commercialhaskell/stack/issues/4292)
* Fix for git packages to update submodules to the correct state. See
[#4314](https://github.com/commercialhaskell/stack/pull/4314)


## v1.9.0.1 (release candidate)
Expand Down
9 changes: 5 additions & 4 deletions subs/pantry/src/Pantry/Repo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,25 @@ getRepo' repo@(Repo url commit repoType' subdir) pm =
dir = tmpdir </> suffix
tarball = tmpdir </> "foo.tar"

let (commandName, cloneArgs, resetArgs, archiveArgs) =
let (commandName, resetArgs, submoduleArgs, archiveArgs) =
case repoType' of
RepoGit ->
( "git"
, ["--recursive"]
, ["reset", "--hard", T.unpack commit]
, ["submodule", "update", "--init", "--recursive"]
, ["archive", "-o", tarball, "HEAD"]
)
RepoHg ->
( "hg"
, []
, ["update", "-C", T.unpack commit]
, []
, ["archive", tarball, "-X", ".hg_archival.txt"]
)

logInfo $ "Cloning " <> display commit <> " from " <> display url
void $ proc
commandName
("clone" : cloneArgs ++ [T.unpack url, suffix])
("clone" : [T.unpack url, suffix])
readProcess_
-- On Windows 10, an upstream issue with the `git clone` command means that
-- command clears, but does not then restore, the
Expand All @@ -101,6 +101,7 @@ getRepo' repo@(Repo url commit repoType' subdir) pm =

withWorkingDir dir $ do
void $ proc commandName resetArgs readProcess_
void $ proc commandName submoduleArgs readProcess_
void $ proc commandName archiveArgs readProcess_
abs' <- resolveFile' tarball
getArchive
Expand Down

0 comments on commit 8bda49d

Please sign in to comment.