RuntimeError if submodule has no branch
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
If a submodule has been added without the --branch option, accessing the Submodule.branch property raises a RuntimeError:
❯❯❯ git init
Initialized empty Git repository in /tmp/gregoire/tmp.R3p5f9ZTwD/.git/
❯❯❯ git submodule add https://github.com/libgit2/pygit2.git pygit2 --branch=master
[...]
❯❯❯ python3 -c 'import pygit2; print(pygit2.Repository(".").lookup_submodule("pygit2").branch)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/gregoire/.local/lib/python3.7/site-packages/pygit2/submodule.py", line 80, in branch
return ffi.string(branch).decode('utf-8')
RuntimeError: cannot use string() on <cdata 'char *' NULL>
It works fine if --branch is added to git submodule add:
❯❯❯ git init
Initialized empty Git repository in /tmp/gregoire/tmp.R3p5f9ZTwD/.git/
❯❯❯ git submodule add https://github.com/libgit2/pygit2.git pygit2
[...]
❯❯❯ python3 -c 'import pygit2; print(pygit2.Repository(".").lookup_submodule("pygit2").branch)'
master
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie bei der Eigenschaft Submodule.branch in pygit2/submodule.py, die der im Bericht gezeigten fehlschlagenden Zeile entspricht, und reproduzieren Sie den Fall mit einem Submodul, das ohne --branch hinzugefügt wurde. Fügen Sie eine Regressionstestabdeckung für diesen Fall hinzu und verifizieren Sie, dass der Zugriff auf branch nun nicht mehr den NULL cdata RuntimeError auslöst und dabei dem beabsichtigten API-Verhalten entspricht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- git, python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100