Repository.merge_file_from_index - can't take a None as an argument
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 408
- Avg merge
- 2d 57m
- Merged PRs (30d)
- 7
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read pygit2/repository.py around line 682 and run the shown test for Repository.merge_file_from_index. Check whether the implementation accepts None for the theirs argument as the signature indicates; done means the behavior and test agree on the deleted-file case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100