Skip to content

Freeze remote repos as well - #8

Merged
hasufell merged 1 commit into
masterfrom
remote-freeze
Sep 30, 2020
Merged

hasufell merged 1 commit into
masterfrom
remote-freeze

Conversation

@hasufell

Copy link
Copy Markdown
Owner

This also fixes #1, because if
a remote repo is a hackage dep, it will
replace the version from the statically stack-generated
freeze info now.

@KtorZ

-- of a git repository.
getPackageIdent :: Git -> IO [PackageIdentifier]
getPackageIdent (Git (T.unpack -> repo) (T.unpack -> commit) (fmap T.unpack -> subdirs)) =
withSystemTempDirectory "stack2cabal" $ \dir -> do

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

We clone into a temp dir and reset to the "offending" commit, then use cabal to parse the .cabal file and get PackageIdentifier. This is semi-expensive, hence optional from the cli. It would be cool to re-use the repos cloned by cabal already, but that would probably require far more work.

freezeRemoteRepos :: Project -> Freeze -> IO Freeze
freezeRemoteRepos (Project { srcs }) (Freeze deps flags) = do
clonedDeps <- fmap concat $ forM srcs $ \src -> getPackageIdent src
let newDeps = fromHM $ H.union (toHM clonedDeps) (toHM deps)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Here's the magic: we merge the freeze files.

Comment thread exe/Main.hs Outdated
)
)
) <*>
(switch (short 'r' <> long "freeze-remotes" <> help "Additionally freeze all remote repos (slower, but more correct, because remote repos also can be hackage deps)")

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I hope this is understandable enough.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What should be "understandable" in this context? The code or the help text?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Help text

Comment thread lib/StackageToHackage/Hackage.hs Resolved
This also fixes #1, because if
a remote repo is a hackage dep, it will
replace the version from the statically stack-generated
freeze info now.
@hasufell
hasufell merged commit 451036f into master Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introspect hackage dependencies specified as git (e.g. in extra-deps)

2 participants