Library repository tag checkout fails when .gitmodules
file is missing
#164
Labels
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
Describe the problem
A Git submodule has two components:
.gitmodules
configuration fileIt turns out it is possible to have a submodule object in a repository even without an accompanying
.gitmodules
entry. For example:https://github.com/m5stack/M5AtomS3/tree/eff2afccf4aebd0ff947b058d0206852f41002e0/examples/Basics/FactoryTest/lib
The
MahonyAHRS
is a submodule, yet there is no.gitmodules
file in the repo (which is why no repo is opened when you click onMahonyAHRS
in that folder listing).🐛 If a library repository has this state, the checkout of the tag fails under these conditions with a cryptic error:
Even though submodules in libraries are not supported in that the release archive will not contain the submodule contents, the presence of a submodule in the library is not prohibited in the Arduino Library Manager requirements. Normally the presence of a submodule only result in a warning from Arduino Lint in the engine run logs:
To reproduce
.gitmodules
file before committing the submodule object.🐛 The tag is not indexed.
Integration test coverage for the bug (currently fails):
ⓘ This was a quick test I threw together with the idea it would help with the investigation. Since the specific conditions the bug occurs under are known and simple to produce, it would be better to use a Go-based test and a generated test data repository to avoid the fragility that results from depending on an external resource (https://github.com/m5stack/M5AtomS3) as test data.
Expected behavior
Library releases that contain a submodule without
.gitmodules
entry are treated the same as any other release with a submodule:- OR -
If it is not possible to work with a repository in this condition:
Additional context
After finding that
github.com/go-git/go-git/v5#Worktree.Status
shows theDeleted
github.com/go-git/go-git/v5.StatusCode
forexamples/Basics/FactoryTest/lib/MahonyAHRS
, I assumed that the post checkout repository cleaning code was causing the deletion of the submodule object from the repository. However, this is not the case.examples/Basics/FactoryTest/lib/MahonyAHRS
is still present even though go-git reports it as being deleted. It reports it as deleted even immediately after the checkout and before any "cleaning" is done on the repository.I tested with the latest version (go-git/go-git@5dabd83) of
github.com/go-git/go-git
and the bug is still present.I expected I could use
github.com/go-git/go-git/v5.Worktree.Submodules
to detect submodules comprehensively. Unfortunately I found it does not detect the submodule when the.gitmodules
file is missing.This makes it more challenging to accomplish the second alternative mentioned under the "Expected behavior" section.
Originally reported by @Tinyu-Zhao at arduino/library-registry#2352 (comment)
Issue checklist
The text was updated successfully, but these errors were encountered: