Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Behavior changes:
Other enhancements:

Bug fixes:
* Fix to allow dependencies on specific versions of local git repositories. See
[#4862](https://github.com/commercialhaskell/stack/pull/4862)


## v2.1.1.1
Expand Down
9 changes: 9 additions & 0 deletions subs/pantry/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog for pantry

## Unreleased changes

**Changes since 0.1.0.0**

Bug fixes:

* Fix to allow dependencies on specific versions of local git repositories. See
[#4862](https://github.com/commercialhaskell/stack/pull/4862)

## 0.1.0.0

* Initial release
33 changes: 16 additions & 17 deletions subs/pantry/src/Pantry/Repo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,13 @@ 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
-- Note we do not immediately change directories into the new temporary directory,
-- but instead wait until we have finished cloning the repo. This is because the
-- repo URL may be a relative path on the local filesystem, and we should interpret
-- it as relative to the current directory, not the temporary directory.
let dir = tmpDir </> "cloned"
(runCommand, resetArgs, submoduleArgs) =
case repoType' of
RepoGit ->
( runGitCommand
Expand All @@ -176,23 +177,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]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment that this is intentionally not run within the withWorkingDir below in order to allow relative paths to work.

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