Closes #1472: Implement in-memory config backend for config overrides in context manager#1473
Open
beamerblvd wants to merge 13 commits into
Open
Closes #1472: Implement in-memory config backend for config overrides in context manager#1473beamerblvd wants to merge 13 commits into
beamerblvd wants to merge 13 commits into
Conversation
`Config` now has two subclasses: `DefaultConfig` and `RepositoryConfig`: - `DefaultConfig` represents the total sum config of program, system, XDG, and global (user) configurations as obtained from `git_config_open_default`. Even if none of those files exist, one can still create an empty `DefaultConfig`. - `RepositoryConfig` represents repository configurations and is the type now returned by `Repository.config` and `Repository.config_snapshot`. - `RepositoryConfig` contains the ability to enter/exit as a context manager, enabling an in-memory config backend with level `GIT_CONFIG_LEVEL_APP`. This allows users to add temporary, in-memory overrides to the repository config that affect repository operations without persisting permanently to the repository's config file.
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 implements #1472. It makes several changes to configs in pygit2, and includes substantial documentation improvements to explain the new classes and methods:
Confighas several internal changes, but externally, its use and behavior is the same.DefaultConfigis a new class that extendsConfigand wrapsgit_config_open_default, which previously was not accessible in pygit2.RepositoryConfigis a new class that extendsConfigand wrapsgit_repository_config/git_repository_config_snapshot(previously these were wrapped directly byConfig).DefaultConfigandRepositoryConfigare constructed, they construct an in-memory config backend with levelConfigLevel.APPthat, initially, is unused. When instances of these classes are entered as a context manager, that in-memory backend is given sole write priority. When instances of these classes are exited as a context manager, that in-memory backend in cleared, and the default write priority is restored.ConfigEntryhas been refactored.