libgit2 / libgit2/pygit2

Repository.merge_file_from_index - can't take a None as an argument

Aperta
#1,378 2 commenti 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

This is probably more of a libgit2 question but given that I am working on pygit2, I better start the conversation over here.

I am working on writing unit tests for Repository.merge_file_from_index. I want to add a test for a deleted file. The signature of the method provides for None as a valid argument:

    def merge_file_from_index(
        self,
        ancestor: typing.Union[None, IndexEntry],
        ours: typing.Union[None, IndexEntry],
        theirs: typing.Union[None, IndexEntry],
    ) -> str:

So I have this:

def test_merge_file_from_index(testrepo):
    hello_txt = testrepo.index["hello.txt"]

    # deleting the file on theirs
    res = testrepo.merge_file_from_index(hello_txt, hello_txt, None)
    assert res == ""

And I am getting this when I run the test:

>       raise GitError(message)
E       _pygit2.GitError: invalid argument: 'theirs'

Am I wrong in my understanding from the signature that None is a correct value?

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

Leggi pygit2/repository.py intorno alla riga 682 ed esegui il test mostrato per Repository.merge_file_from_index. Verifica se l'implementazione accetta None per l'argomento theirs, come indicato dalla firma; il lavoro è completato quando il comportamento e il test concordano nel caso di un file eliminato.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.