libgit2 / libgit2/pygit2

Global config cannot be set if ~/.gitconfig does not exist yet

Offen
#915 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
1.7k
Forks
408
Ø Merge
2 T. 57 Min.
Gemergte PRs (30 T.)
7

Beschreibung

When there is no ~/.gitconfig, the following code snippet

import pygit2
global_config = pygit2.Config.get_global_config() # ← Exception raised here
global_config['user.email'] = 'me@example.org'

fails with

Traceback (most recent call last):
  File "global_config.py", line 2, in <module>
    global_config = pygit2.Config.get_global_config()
  File "/usr/lib/python3/dist-packages/pygit2/config.py", line 281, in get_global_config
    return Config._from_found_config(C.git_config_find_global)
  File "/usr/lib/python3/dist-packages/pygit2/config.py", line 265, in _from_found_config
    check_error(err, True)
  File "/usr/lib/python3/dist-packages/pygit2/errors.py", line 53, in check_error
    raise IOError(message)
OSError: the global file '.gitconfig' doesn't exist: No such file or directory

I.e.,

  1. there seems to be no way of setting a global option unless ~/.gitconfig already exists.
  2. There seems to be no way to create the global config file ahead of time, at least not in a portable way (I doubt it is in ~/.gitconfig on Windows systems).

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, das bereitgestellte Python-Snippet ohne ~/.gitconfig zu reproduzieren, und untersuche dann pygit2/config.py, insbesondere Config.get_global_config und _from_found_config. Die Behebung ist abgeschlossen, wenn eine globale Option ohne vorhandene globale Konfigurationsdatei gesetzt werden kann, auch auf Plattformen, auf denen sich deren Speicherort unterscheidet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
git, python
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
58/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.