pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

pygit2 unable to commit changes

Open som-kanade opened this issue 4 years ago • 1 comments

pygit2 == 1.7.0

I have been trying to commit changes to repo but unable to do so

snippet oid = repository.create_commit(<branch_name>, author, commiter, message, tree, [repository.head.get_object().hex]) author and commiter are already defined

looks like get_object. was deprecated in newer version . are there any work arounds in latest version for commiting changes

error >>

KeyError: 'the requested type does not match the type in the ODB'

let know if any more details are needed

som-kanade avatar Oct 20 '21 20:10 som-kanade

I think repository.head.target.raw should work.

According to the docs previous commits are a list of binary strings

Commits can be created by calling the ``create_commit`` method of the
repository with the following parameters::

    >>> author = Signature('Alice Author', '[email protected]')
    >>> committer = Signature('Cecil Committer', '[email protected]')
    >>> tree = repo.TreeBuilder().write()
    >>> repo.create_commit(
    ... 'refs/heads/master', # the name of the reference to update
    ... author, committer, 'one line commit message\n\ndetailed commit message',
    ... tree, # binary string representing the tree object ID
    ... [] # list of binary strings representing parents of the new commit
    ... )
    '#\xe4<u\xfe\xd6\x17\xa0\xe6\xa2\x8b\xb6\xdc35$\xcf-\x8b~'

amosson avatar Oct 21 '21 14:10 amosson