Updated docs to match new branches API.
This commit is contained in:
parent
d14438725e
commit
d6716e035a
docs
@ -49,7 +49,7 @@ example `three-argument rebases`_.
|
|||||||
repo = pygit2.Repository('/path/to/repo')
|
repo = pygit2.Repository('/path/to/repo')
|
||||||
|
|
||||||
cherry = repo.revparse_single('9e044d03c')
|
cherry = repo.revparse_single('9e044d03c')
|
||||||
basket = repo.lookup_branch('basket')
|
basket = repo.branches.get('basket')
|
||||||
|
|
||||||
base = repo.merge_base(cherry.oid, basket.target)
|
base = repo.merge_base(cherry.oid, basket.target)
|
||||||
base_tree = cherry.parents[0].tree
|
base_tree = cherry.parents[0].tree
|
||||||
|
@ -69,28 +69,35 @@ Branches
|
|||||||
Branches inherit from References, and additionally provide specialized
|
Branches inherit from References, and additionally provide specialized
|
||||||
accessors for some unique features.
|
accessors for some unique features.
|
||||||
|
|
||||||
.. automethod:: pygit2.Repository.listall_branches
|
.. automethod:: pygit2.Repository.Branches.create
|
||||||
.. automethod:: pygit2.Repository.lookup_branch
|
.. automethod:: pygit2.Repository.Branches.delete
|
||||||
.. automethod:: pygit2.Repository.create_branch
|
.. automethod:: pygit2.Repository.Branches.get
|
||||||
|
.. automethod:: pygit2.Repository.Branches.__getitem__
|
||||||
|
.. automethod:: pygit2.Repository.Branches.__iter__
|
||||||
|
.. automethod:: pygit2.Repository.Branches.__contains__
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
>>> local_branches = repo.listall_branches()
|
>>> # Listing all branches
|
||||||
>>> # equivalent to
|
>>> branches_list = list(repo.branches)
|
||||||
>>> local_branches = repo.listall_branches(pygit2.GIT_BRANCH_LOCAL)
|
>>> # Local only
|
||||||
|
>>> local_branches = list(repo.branches.local)
|
||||||
|
>>> # Remote only
|
||||||
|
>>> remote_branches = list(repo.branches.remote)
|
||||||
|
|
||||||
>>> remote_branches = repo.listall_branches(pygit2.GIT_BRANCH_REMOTE)
|
>>> # Get a branch
|
||||||
|
>>> branch = repo.branches['master']
|
||||||
|
>>> other_branch = repo.branches['does-not-exist'] # Will raise a KeyError
|
||||||
|
>>> other_branch = repo.branches.get('does-not-exist') # Returns None
|
||||||
|
|
||||||
>>> all_branches = repo.listall_branches(pygit2.GIT_BRANCH_REMOTE |
|
>>> remote_branch = repo.branches.remote['upstream/feature']
|
||||||
pygit2.GIT_BRANCH_LOCAL)
|
|
||||||
|
|
||||||
>>> master_branch = repo.lookup_branch('master')
|
>>> # Create a local branch
|
||||||
>>> # equivalent to
|
>>> new_branch = repo.branches.local.create('new-branch')
|
||||||
>>> master_branch = repo.lookup_branch('master',
|
|
||||||
pygit2.GIT_BRANCH_LOCAL)
|
>>> And delete it
|
||||||
|
>>> repo.branches.delete('new-branch')
|
||||||
|
|
||||||
>>> remote_branch = repo.lookup_branch('upstream/feature',
|
|
||||||
pygit2.GIT_BRANCH_REMOTE)
|
|
||||||
|
|
||||||
The Branch type
|
The Branch type
|
||||||
====================
|
====================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user