MCPcopy Index your code
hub / github.com/gitless-vcs/gitless / Branch

Class Branch

gitless/core.py:618–1291  ·  view source on GitHub ↗

An independent line of development. Attributes: branch_name: the name of this branch. upstream: the upstream of this branch. is_current: True if this branch is the current branch in the repository it belongs to. merge_in_progress: True if a merge op is in progress on this br

Source from the content-addressed store, hash-verified

616
617
618class Branch(object):
619 """An independent line of development.
620
621 Attributes:
622 branch_name: the name of this branch.
623 upstream: the upstream of this branch.
624 is_current: True if this branch is the current branch in the repository it
625 belongs to.
626 merge_in_progress: True if a merge op is in progress on this branch.
627 fuse_in_progress: True if a fuse op is in progress on this branch.
628 head: commit that is the head of this branch.
629 """
630
631 def __init__(self, git_branch, gl_repo):
632 self.git_branch = git_branch
633 self.gl_repo = gl_repo
634 self.branch_name = self.git_branch.branch_name
635
636 def delete(self):
637 if self.is_current:
638 raise BranchIsCurrentError('Can\'t delete the current branch')
639
640 self.git_branch.delete()
641
642 # We also cleanup any stash left
643 s_id, _ = _stash(_stash_msg(self.branch_name))
644 if s_id:
645 git.stash.drop(s_id)
646
647 @property
648 def upstream(self):
649 git_upstream = self.git_branch.upstream
650 if not git_upstream:
651 return None
652
653 try:
654 git_upstream.remote_name
655 return RemoteBranch(git_upstream, self.gl_repo)
656 except ValueError: # Upstream is a local branch
657 return Branch(git_upstream, self.gl_repo)
658
659 @upstream.setter
660 def upstream(self, new_upstream):
661 self.git_branch.upstream = new_upstream.git_branch if new_upstream else None
662
663 @property
664 def head(self):
665 self._update()
666 return self.git_branch.peel()
667
668 @head.setter
669 def head(self, new_head):
670 self.gl_repo.git_repo.reset(new_head, pygit2.GIT_RESET_SOFT)
671
672 @property
673 def target(self):
674 """Object Id of the commit this branch points to."""
675 self._update()

Callers 3

create_branchMethod · 0.85
lookup_branchMethod · 0.85
upstreamMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected