From 8bda49d9bd6030920a6c23aa82fcc98b6cd8137b Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 21 Sep 2018 08:20:22 -0700 Subject: [PATCH 1/2] Update git package submodules after clone and reset 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) --- ChangeLog.md | 2 ++ subs/pantry/src/Pantry/Repo.hs | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index ead71d1615..8dbe254c81 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) ## v1.9.0.1 (release candidate) diff --git a/subs/pantry/src/Pantry/Repo.hs b/subs/pantry/src/Pantry/Repo.hs index 6edd148caa..e93c40257b 100644 --- a/subs/pantry/src/Pantry/Repo.hs +++ b/subs/pantry/src/Pantry/Repo.hs @@ -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 @@ -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 From 80746024f2d89c5783e9dbd90dd54e7da6dfdafb Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 24 Sep 2018 08:00:25 -0500 Subject: [PATCH 2/2] SubmoduleArgs in Maybe --- subs/pantry/src/Pantry/Repo.hs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/subs/pantry/src/Pantry/Repo.hs b/subs/pantry/src/Pantry/Repo.hs index e93c40257b..c93cc876c9 100644 --- a/subs/pantry/src/Pantry/Repo.hs +++ b/subs/pantry/src/Pantry/Repo.hs @@ -76,21 +76,20 @@ getRepo' repo@(Repo url commit repoType' subdir) pm = RepoGit -> ( "git" , ["reset", "--hard", T.unpack commit] - , ["submodule", "update", "--init", "--recursive"] + , 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" : [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,9 +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 submoduleArgs readProcess_ - void $ proc commandName archiveArgs readProcess_ + runCommand resetArgs + traverse_ runCommand submoduleArgs + runCommand archiveArgs abs' <- resolveFile' tarball getArchive (PLIRepo repo pm)