Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add option to omit hash #380

Closed
simfleischman opened this issue Mar 19, 2020 · 3 comments
Closed

Feature request: add option to omit hash #380

simfleischman opened this issue Mar 19, 2020 · 3 comments

Comments

@simfleischman
Copy link

Problem

The generated cabal file has a hash at the top. Example:

-- This file has been generated from package.yaml by hpack version 0.31.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: f4d99c3891788b8cb735558ccd259cf1ab897bfdba73efd7266f137e584c7357

The hash is useful for checking whether or not to regenerate the cabal file and save directory traversals and the other work hpack does.

However, it forces a source-control conflict every time the backed package.yaml is updated in separate commits and if the generated cabal file is in source control.

Having the generated file in source control has its tradeoffs, but there are reasons why one would want to do so. One reason is to avoid unnecessary work. Another reason is having consistent builds, which may be affected by having to generate files. I mention these reasons not because everyone should do this, but because there are reasonable reasons to check-in the generated cabal file, and doing so has the effect of frequent source conflicts.

Proposed solution

Add option

Add an option in the package.yaml file to omit generating the hash.

Proposed option: hpack-hash specified as an optional top-level attribute of type boolean with default value of true.

Other choices: generated-hash or just hash.

Behavior

In terms of hpack behavior, always regenerate the cabal file seems the most correct course of action. However it is not the most efficient. But perhaps that is the tradeoff of using this feature.

@simonmichael
Copy link

simonmichael commented Mar 31, 2020

Yes please! This would absolutely be a more useful default for me when using stack. Regenerating based on modification time would be just fine, and I don’t need to know which version of hpack it was. This would mean I no longer have to commit cabal file updates separately to avoid conflicts. (And committing cabal files is essential for interop with the non hpack world, and for calming the anti-hpack drumbeat in #haskell btw).

@simfleischman
Copy link
Author

#390 addresses my request.

@sol
Copy link
Owner

sol commented May 14, 2020

As already hinted at #390 (comment), I'm tempted to remove the hash feature entirely with 0.35.0.

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

No branches or pull requests

3 participants