Suggestion: better handling of `repo.set_head(pygit2.Commit)`
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
I have tried to emulate git checkout --detach <commit> in pygit2, to create detached HEAD checkout, and I did come up with the following rough equivalent (though the following does not uses transactions as git does):
rev = repo.revparse_single(commit_name)
repo.checkout_tree(rev)
repo.set_head(rev.id)
However when I tried to use simply repo.set_head(rev), I got the following error:
TypeError Traceback (most recent call last)
<ipython-input-35-9612528ec0ac> in <module>()
----> 1 repo.set_head(rev)
/usr/lib/python2.7/dist-packages/pygit2/repository.pyc in set_head(self, target)
293
294 # if it's a string, then it's a reference name
--> 295 err = C.git_repository_set_head(self._repo, to_bytes(target))
296 check_error(err)
297
TypeError: initializer for ctype 'char *' must be a cdata pointer, not _pygit2.Commit
It would be nice if pygit2.Commit object was automatically peeled, but if it is decided to be not good idea, then what it needs is more user-friendly error message than the one above.
pygit2 0.26.0
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
Beginne bei Repository.set_head im repository.py-Traceback und vergleiche den dort gezeigten Ablauf von revparse_single, checkout_tree und C.git_repository_set_head. Prüfe bestehende Tests oder Dokumentation auf akzeptierte Zieltypen; abgeschlossen ist es, wenn das Verhalten bei Commit-Eingaben geklärt und abgedeckt ist, einschließlich einer eindeutigen Fehlermeldung, falls es weiterhin nicht unterstützt wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- git, python
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100