libgit2 / libgit2/pygit2

Suggestion: better handling of `repo.set_head(pygit2.Commit)`

Aperta
#750 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
1.7k
Fork
408
Merge medio
2g 57m
PR unite (30g)
7

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da Repository.set_head nel traceback di repository.py e confronta il flusso mostrato di revparse_single, checkout_tree e C.git_repository_set_head. Controlla nei test o nella documentazione esistenti quali tipi di destinazione sono accettati; il lavoro è completo quando il comportamento dell'input Commit è definito e coperto, incluso un messaggio di errore chiaro se rimane non supportato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
git, python
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.