Skip to content

Require a revision 0 cabal file when force-version is used#118

Merged
angerman merged 1 commit intomainfrom
nm/stable-forced-versions
Feb 16, 2026
Merged

Require a revision 0 cabal file when force-version is used#118
angerman merged 1 commit intomainfrom
nm/stable-forced-versions

Conversation

@neilmayhew
Copy link
Copy Markdown
Contributor

Instead of rewriting the cabal file, we use an archived version that's stored as revision 0. This avoids changing existing cabal files when Cabal's pretty-printing changes.

@neilmayhew neilmayhew requested a review from angerman February 12, 2026 23:21
neilmayhew added a commit to IntersectMBO/cardano-haskell-packages that referenced this pull request Feb 12, 2026
This brings in input-output-hk/foliage#118 which uses a revision-0 cabal
file instead of reformatting the upstream one when the version is forced

This avoids changing already-released cabal files when Cabal's
pretty-printing changes
@neilmayhew neilmayhew force-pushed the nm/stable-forced-versions branch 2 times, most recently from 7e97cf2 to c2ac715 Compare February 14, 2026 00:26
neilmayhew added a commit to IntersectMBO/cardano-haskell-packages that referenced this pull request Feb 14, 2026
This brings in input-output-hk/foliage#118 which uses a revision-0 cabal
file instead of reformatting the upstream one when the version is forced

This avoids changing already-released cabal files when Cabal's
pretty-printing changes
@neilmayhew
Copy link
Copy Markdown
Contributor Author

This works in tandem with IntersectMBO/cardano-haskell-packages#1256 which modifies the add-from-github.sh script to create revisions/0.cabal when forcing a version.

Although the script uses a text-substitution approach, rather than the AST-based rewriting that was previously done by foliage, I think that's relatively robust because the text substitution is being done when the script is run interactively by a human, and it displays a diff of the cabal file afterwards so the user can see exactly what was changed (and it should be only the version number). In other words, there's some human oversight. After that, the file is committed to git and will never change again.

The only change to foliage here is to require a 0.cabal file from the git repo, instead of rewriting the file from the tarball during the build. I actually feel safer with this than with a reformatting of the file that makes it very difficult for a human to check what has changed.

neilmayhew added a commit to IntersectMBO/cardano-haskell-packages that referenced this pull request Feb 14, 2026
This brings in input-output-hk/foliage#118 which uses a revision-0 cabal
file instead of reformatting the upstream one when the version is forced

This avoids changing already-released cabal files when Cabal's
pretty-printing changes
@andreabedini
Copy link
Copy Markdown
Contributor

This is good. I wonder if we simplify the process.

  • deprecate force-version
  • pkg-name/pkg-version/revisions/0.cabal always replaces the cabal file when it exists.

What is annoying is that we have the package name and package version in the path already. As it stands foliage simply checks that the two sources of package version (the path and the metadata) matches but TBH I find this unsatisfactory. Nevertheless, this change does not improve or regress w.r.t to this duplication, so that is not a problem.

Copy link
Copy Markdown
Contributor

@andreabedini andreabedini left a comment

Choose a reason for hiding this comment

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

This looks good as it stands.

@angerman
Copy link
Copy Markdown
Contributor

Alright let's do this then.

@angerman angerman merged commit 5283d01 into main Feb 16, 2026
5 checks passed
@angerman angerman deleted the nm/stable-forced-versions branch February 16, 2026 08:13
angerman pushed a commit to IntersectMBO/cardano-haskell-packages that referenced this pull request Feb 17, 2026
This brings in input-output-hk/foliage#118 which uses a revision-0 cabal
file instead of reformatting the upstream one when the version is forced

This avoids changing already-released cabal files when Cabal's
pretty-printing changes
angerman pushed a commit to IntersectMBO/cardano-haskell-packages that referenced this pull request Feb 17, 2026
This brings in input-output-hk/foliage#118 which uses a revision-0 cabal
file instead of reformatting the upstream one when the version is forced

This avoids changing already-released cabal files when Cabal's
pretty-printing changes
angerman pushed a commit to IntersectMBO/cardano-haskell-packages that referenced this pull request Feb 17, 2026
This brings in input-output-hk/foliage#118 which uses a revision-0 cabal
file instead of reformatting the upstream one when the version is forced

This avoids changing already-released cabal files when Cabal's
pretty-printing changes
@neilmayhew
Copy link
Copy Markdown
Contributor Author

Thanks for the review, Andrea.

  • deprecate force-version
  • pkg-name/pkg-version/revisions/0.cabal always replaces the cabal file when it exists.

I agree that this would be a good improvement. Then, force-version simply becomes an artifact of the add-from-github.sh script.

I'll create a PR for this.

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.

3 participants