Skip to content

Improve handling of erroneous dirty library repo state after release checkout #42

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

Merged
merged 5 commits into from
May 28, 2021
Merged

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented May 28, 2021

Even though in theory it shouldn't ever be necessary to do a hard reset in this application, under certain circumstances, go-git can fail to complete checkout, while not even returning an error (go-git/go-git#99). The resulting dirty repository state would cause Library Manager to serve a corrupted release. A hard reset after each checkout ensures that the repository is at its tagged state.

The previous checkout behavior resulted in the ssd1306@1.0.0 release being indexed, even though the repository contains a .exe file at that tag:
https://github.com/lexus2k/ssd1306/tree/v1.0.0/tools
By chance, this incomplete checkout removed the .exe file from the release, which allowed it to pass validation. Although harmless in this particular case, incomplete checkouts could cause big problems if essential files went missing from releases, and so must be avoided, by recovering when possible, and skipping the release when not possible.

@per1234 per1234 added type: bug topic: code Related to content of the project itself labels May 28, 2021
per1234 added 5 commits May 28, 2021 04:29
The code for checking out tags was duplicated. Already fairly complex, it turns out to need even more code to work reliably. For this reason, it will be beneficial to move it to a function in the gitutils package to avoid code duplication and facilitate testing.
The engine's Git code is failing to get a clean checkout of releases under some circumstances. This resulted in the ssd1306@1.0.0 release being accepted even though the repository contains a .exe at that tag. However, the engine's checkout code fails to add the .exe when checking out this tag, leaving the repository in a dirty state that just so happens to allow it to pass validation. Although harmless in this particular situation, this could cause big problems if essential files went missing from releases, and so must be tested for.
Even though in theory it shouldn't ever be necessary to do a hard reset in this application, under certain circumstances, go-git can fail to complete checkout, while not even returning an error. The resulting dirty repository state would cause Library Manager to serve a corrupted release. A hard reset after each checkout ensures that the repository is at its tagged state.
Under certain circumstances, go-git can fail to complete checkout, while not even returning an error. While the clean and hard reset processes should ensure this is corrected, the fact that it is necessary casts doubt on the reliability of go-git.

It's very important that the releases distributed by Library Manager match the repository, so it's better to reject any releases that can't be brought into a clean state.
It's not certain that there is any point in another try after a first unsuccessful cleaning attempt. However, go-git's checkout code also does a hard reset, but still leaves the repository dirty under certain circumstances. Running an identical hard reset procedure again gets the repository to a clean state, so this indicates a possibility that a retry might be successful.
@per1234 per1234 merged commit f162ba3 into arduino:main May 28, 2021
@per1234 per1234 deleted the reset branch May 28, 2021 13:05
@rsora rsora added the type: imperfection Perceived defect in any part of project label Sep 22, 2021
@per1234 per1234 self-assigned this Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants