Submodule init, update, caching, reload, status #1248
Merged
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.
This PR fleshes out submodules a bit.
Repository.init_submodules
andupdate_submodules
(which would do a redundant submodule lookup). Those two functions still exist in Repository, but they are now convenience wrappers around the new init/update functions in all the submodules in the repo.Notes about API design: The PR brings in new enums (GIT_SUBMODULE_STATUS_...) that I encapsulated as enum classes (IntFlag, IntEnum) in
enums.py
.This allows for friendlier development – function signatures can say they return a
SubmoduleStatus
instead of just anint
, and callingrepr
on aSubmoduleStatus
returns more descriptive text than just a number, such as:<SubmoduleStatus.IN_HEAD|IN_INDEX|IN_CONFIG|WD_UNINITIALIZED: 135>
This isn't how pygit2 currently exposes enums to Python code – but if you think it'd improve pygit2, we could progressively convert the existing enums to IntFlag/IntEnum classes. (The raw GIT_* values would still be available for legacy code.)
If you'd rather not have
enums.py
for consistency with the existing API, let me know and I'll edit this PR accordingly.