Provide example for Reference.log_append
I would have found this useful when trying to do reflog additions. It might not be massively complex but examples always help.
This commit is contained in:
@@ -27,6 +27,23 @@ The Reference type
|
|||||||
.. automethod:: pygit2.Reference.resolve
|
.. automethod:: pygit2.Reference.resolve
|
||||||
.. automethod:: pygit2.Reference.log
|
.. automethod:: pygit2.Reference.log
|
||||||
.. automethod:: pygit2.Reference.log_append
|
.. automethod:: pygit2.Reference.log_append
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
>>> branch = repository.lookup_reference("refs/heads/master")
|
||||||
|
>>> branch.target = another_commit.id
|
||||||
|
>>> committer = Signature('Cecil Committer', 'cecil@committers.tld')
|
||||||
|
>>> branch.log_append(another_commit.id, committer,
|
||||||
|
"changed branch target using pygit2")
|
||||||
|
|
||||||
|
This creates a reflog entry in ``git reflog master`` which looks like::
|
||||||
|
|
||||||
|
7296b92 master@{10}: changed branch target using pygit2
|
||||||
|
|
||||||
|
In order to make an entry in ``git reflog``, ie. the reflog for ``HEAD``, you
|
||||||
|
have to get the Reference object for ``HEAD`` and call ``log_append`` on
|
||||||
|
that.
|
||||||
|
|
||||||
.. automethod:: pygit2.Reference.get_object
|
.. automethod:: pygit2.Reference.get_object
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user