Submodule init, update, caching, reload, status#1248
Merged
Conversation
This allows updating individual Submodule instances when you already have them, instead of going through Repository (which would do a redundant submodule lookup).
Member
|
Merged, thanks. My only concern is the API consistency of the I think it would be best to do like the remotes and have: With the old function names kept for backwards compatibility, as deprecated. What do you think? Do you mind to make a new PR in that direction? |
Contributor
Author
|
I agree, this looks better. I'll submit a new PR this week! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_submodulesandupdate_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
SubmoduleStatusinstead of just anint, and callingrepron aSubmoduleStatusreturns 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.pyfor consistency with the existing API, let me know and I'll edit this PR accordingly.