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
Enable spago init
and spago upgrade-set
to use user-specified package-set tag rather than latest release
#680
Conversation
Note: tag is not verified to actually exist in this PR
- modifyPackageSetVersion -> updatePackageSetVersion - updatePackageSet -> useLatestRelease
I've rebased the code on master and accounted for your feedback. When renaming |
A few thoughts on this. In your comment in #370, you list the following things that would make this done:
1 and 2 have been done. How should number 3 be done, and what should my involvement with that be? |
@JordanMartinez in the issue you link I proposed that we check the GitHub releases of the repo before patching, to make sure that the tag exists. And the reason why I proposed such solution is only so that we're able to give a decent error message to the user, and prevent silent failure. Currently this are the error messages that the user gets when they input a tag that doesn't exist (this is for
It's good that we fail immediately and do not edit the file with the wrong tag, but the message could probably be better? I think we should merge this as is, and we can take care of error message improvements in another pull request (it could be you or someone else, and ideally it would happen before the next release) About strategies for improving the error message:
|
@JordanMartinez re breaking changes: we don't support at all people using Spago as a library, since we don't even publish to Hackage. The current versioning system only cares about breaking changes from the CLI perspective - that's the only API that we guarantee at the moment, so it's fine to change internal things |
Sorry, let me be clearer. I understand (and agree!) that we want a better error message and to verify that the package set actually exists before we patch If this PR was merged, I would want to update the message above to say "unsafely patching |
Note that we are already throwing an error before we patch the file, which is the behaviour we want here.
I apologize for not explaining myself clearly in my previous message: I think that all the three ways I described in the past and that you quote here are overly complicated and should not be implemented, and we can get by with implementing one of the two solutions I mentioned above (i.e. catching the error that Dhall gives us or verifying ourseves that we get a 404 when fetching a non-existent package set - I can detail more if you'd like), which are dramatically simpler to implement. |
I've done some digging and here's what I've found. First, in Second, the error message we get is an Since I'm not familiar with Haskell, can these exceptions be caught? |
Note: Spago.Config uses `Dhall.writeRawExpr` and `PackageSet.useLatestRelease` doesn't need to verify the package set exists. Thus, I duplicated `writeRawExpr` as `writeRawExprPostVerify` so that the package set verification can be done specifically in `PackageSet.useSpecificRelease`
Current error message:
The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for digging into this! I left some refactoring comments, but otherwise looks great 👍
Reduces code duplication
Reduce code duplication
I updated the code a bit before I read your messages. I only print the 'package set does not exist' message when we get a 404 specifically. Otherwise, someone might be mislead by a 5xx error. Current output:
|
...might help if I pushed the commits I just made... |
spago init
and spago upgrade-set
to use user-specified package-set tag rather than latest release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left only some tiny suggestions, but otherwise this looks amazing, great work! 👏
Would you like to put together some tests or should we merge now and take care of the tests later?
I looked at the tests for a bit and wasn't quite sure how to write it. I'll likely need more guidance. We should likely add the tests here so the entire things is self-contained, but it's up to you. |
Ah, nevermind. I think I got the hang of if now. |
Besides coming to an agreement as to how certain things should be rendered, I think this PR is done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is done indeed! Thank you for doing this 🙂
We squash-merge as a rule, so I added you as a collaborator to the repo and you can reshuffle the commit message and merge yourself.
Description of the change
Fixes #370 by implementing the feature but doesn't have Spago check whether the user-specified tag is valid.
Checklist:
README
P.S.: the above checks are not compulsory to get a change merged, so you may skip them. However, taking care of them will result in less work for the maintainers and will be much appreciated 😊