Feature Request: Support app-level temporary config overrides using libgit2's backend supprt
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 45/100
Direção de pesquisa
Comece revisando a classe Config existente e os wrappers propostos DefaultConfig e RepositoryConfig em torno de git_config_open_default e git_repository_config. Verifique como o backend APP em memória deve se comportar como um gerenciador de contexto e, em seguida, confirme que as operações do Git só veem os overrides dentro do contexto e que as alterações não persistem após a saída.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
When using the git CLI, you can temporarily override / add config values with -c <name>=<value> (and also --config-env=<name>=<envvar>, but that's just a wrapper around -c to keep secret values off the command line). The important key to -c is that it doesn't persist to a file—the config value lives only so long as that process executes, and then it goes away. Pygit2 has no such support for temporary overrides like this—any changes to a Config persist to disk.
libgit2 can support this using config backends. Currently, libgit2 comes with two kinds of config backends—file backends (the standard type) and a read-only in-memory backend constructed from strings. We could, in theory, use the read-only in-memory backend, but its use wouldn't be very Pythonic, and also it's not until the unreleased libgit 1.9.5 that it's possible to construct this backend from the public API (prior to 1.9.5, it was private).
But libgit2's public API supports implementing and attaching any arbitrary custom backend, and it's fairly straightforward (if not verbose) to implement a mutable in-memory backend with CFFI + Python.
As an aside, pygit2 is also lacking a wrapper around git_config_open_default, which is relevant to the approach I'm taking.
With the pull request I'm posting shortly, Config (without any public API breakage) becomes a fully-functional base class that, on its own, does what it has always done: wraps access to configuration files. Two new classes DefaultConfig and RepositoryConfig now extend Config: the former wrapping git_config_open_default and the latter wrapping git_repository_config/git_repository_config_snapshot. Both of these subclasses can now act as context managers for in-memory config overrides. An in-memory backend attached with level APP supports these overrides. When the context manager is entered, the in-memory backend is made the highest priority for writes. When the context manager is exited, the in-memory backend is cleared and made the lowest priority for writes. Within the scope of this context manager, Git operations use these overrides. A hypothetical Python-based alternative Git CLI could, then, implement -c and --config-env using this context manager.
The detailed documentation I have written for these classes explains in more detail.
- Linguagem predominante
- Python
- Estrelas
- 1.7k
- Forks
- 408
- Merge médio
- 1d 15h
- PRs com merge (30d)
- 7
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de libgit2/pygit2
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 48/100
-
merge_bases not wrappedAberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 48/100
Todas as issues de libgit2/pygit2
Issues semelhantes
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")Talvez já em andamento @mayureshsonawane17 assumiu hoje. AbertaWaiting for: Product Owner
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Mantenedores costumam responder em até 5 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
bojieli/ai-agent-book#1169 ·
Mantenedores costumam responder em até 1 dia
-
priority:low ready-for-dev
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
OpenHands/extensions#738 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
micronaut-projects/micronaut-core#13677 ·
Mantenedores costumam responder em até 1 dia