diff --git a/ChangeLog.md b/ChangeLog.md index 948d33d0d7..d7e5694ec9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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) * Add `--cabal-files` flag to `stack ide targets` command. diff --git a/subs/pantry/src/Pantry/Repo.hs b/subs/pantry/src/Pantry/Repo.hs index 6edd148caa..c93cc876c9 100644 --- a/subs/pantry/src/Pantry/Repo.hs +++ b/subs/pantry/src/Pantry/Repo.hs @@ -71,26 +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] + , Just ["submodule", "update", "--init", "--recursive"] , ["archive", "-o", tarball, "HEAD"] ) RepoHg -> ( "hg" - , [] , ["update", "-C", T.unpack commit] + , Nothing , ["archive", tarball, "-X", ".hg_archival.txt"] ) + let runCommand args = void $ proc commandName args readProcess_ + logInfo $ "Cloning " <> display commit <> " from " <> display url - void $ proc - commandName - ("clone" : cloneArgs ++ [T.unpack url, suffix]) - readProcess_ + runCommand ("clone" : [T.unpack url, suffix]) -- On Windows 10, an upstream issue with the `git clone` command means that -- command clears, but does not then restore, the -- ENABLE_VIRTUAL_TERMINAL_PROCESSING flag for native terminals. The @@ -100,8 +99,9 @@ getRepo' repo@(Repo url commit repoType' subdir) pm = unless created $ throwIO $ FailedToCloneRepo repo withWorkingDir dir $ do - void $ proc commandName resetArgs readProcess_ - void $ proc commandName archiveArgs readProcess_ + runCommand resetArgs + traverse_ runCommand submoduleArgs + runCommand archiveArgs abs' <- resolveFile' tarball getArchive (PLIRepo repo pm)