Skip to content

Commit

Permalink
Don't change directories when cloning a repo
Browse files Browse the repository at this point in the history
This was making it impossible to use relative file paths as repo URLs.
  • Loading branch information
amalloy committed Jun 15, 2019
1 parent 3a759a7 commit b90cf52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ Bug fixes:
[#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)
* Fix to allow dependencies on specific versions of local git repositories. See
[#4862](https://github.com/commercialhaskell/stack/pull/4862)
* Add `--cabal-files` flag to `stack ide targets` command.
* Don't download ghc when using `stack clean`.
* Support loading in GHCi definitions from symlinked C files. Without this
Expand Down
29 changes: 12 additions & 17 deletions subs/pantry/src/Pantry/Repo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,9 @@ withRepo
-> RIO env a
-> RIO env a
withRepo repo@(Repo url commit repoType' _subdir) action =
withSystemTempDirectory "with-repo" $
\tmpdir -> withWorkingDir tmpdir $ do
let suffix = "cloned"
dir = tmpdir </> suffix

let (runCommand, resetArgs, submoduleArgs) =
withSystemTempDirectory "with-repo" $ \tmpDir -> do
let dir = tmpDir </> "cloned"
(runCommand, resetArgs, submoduleArgs) =
case repoType' of
RepoGit ->
( runGitCommand
Expand All @@ -176,23 +173,21 @@ withRepo repo@(Repo url commit repoType' _subdir) action =
, ["update", "-C", T.unpack commit]
, Nothing
)
fixANSIForWindows =
-- 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
-- folowing hack re-enables the lost ANSI-capability.
when osIsWindows $ void $ liftIO $ hSupportsANSIWithoutEmulation stdout

logInfo $ "Cloning " <> display commit <> " from " <> display url
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
-- folowing hack re-enables the lost ANSI-capability.
when osIsWindows $ void $ liftIO $ hSupportsANSIWithoutEmulation stdout
runCommand ["clone", T.unpack url, dir]
fixANSIForWindows
created <- doesDirectoryExist dir
unless created $ throwIO $ FailedToCloneRepo repo

withWorkingDir dir $ do
runCommand resetArgs
traverse_ runCommand submoduleArgs
-- On Windows 10, an upstream issue with the `git submodule` command means
-- that command clears, but does not then restore, the
-- ENABLE_VIRTUAL_TERMINAL_PROCESSING flag for native terminals. The
-- folowing hack re-enables the lost ANSI-capability.
when osIsWindows $ void $ liftIO $ hSupportsANSIWithoutEmulation stdout
fixANSIForWindows
action

0 comments on commit b90cf52

Please sign in to comment.