Fix LSP removing static downloads and git refs from lockfile on save #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #129
This PR tweaks the
load_project
function, which is where lockfiles are generated and updated. In this code, we were skipping overBrioche.download
andBrioche.gitRef
statics in the context of the LSP (wherefully_valid
is false), which meant that the lockfile that got built by the LSP would never have any download or git ref statics in it. When the LSP saves a file, we would write this recomputed lockfile (in order to update dependencies, which were handled correctly). The updated lockfile would therefore save as if the project had noBrioche.download
orBrioche.gitRef
statics included, removing them even if they were already present in the existing lockfile.As a fix, we just copy over the
Brioche.download
andBrioche.gitRef
statics from the existing lockfile if present, even if those statics are no longer used in the project. My thought was that, if someone commented out aBrioche.download
, saved the project, then uncommented theBrioche.download
, we wouldn't want to get rid of the download static in between. So, this means that the only way to removeBrioche.download
/Brioche.gitRef
statics from the lockfile is to let the CLI update it (e.g. withbrioche check
,brioche build
, etc)