MCPcopy
hub / github.com/gitless-vcs/gitless / RemoteBranch

Class RemoteBranch

gitless/core.py:573–615  ·  view source on GitHub ↗

A branch that lives on some remote repository. Attributes: branch_name: the name of this branch. remote_name: the name of the remote that represents the remote repository where this branch lives. head: commit that is the head of this branch.

Source from the content-addressed store, hash-verified

571
572
573class RemoteBranch(object):
574 """A branch that lives on some remote repository.
575
576 Attributes:
577 branch_name: the name of this branch.
578 remote_name: the name of the remote that represents the remote repository
579 where this branch lives.
580 head: commit that is the head of this branch.
581 """
582
583 def __init__(self, git_branch, gl_repo):
584 self.git_branch = git_branch
585 self.gl_repo = gl_repo
586 self.remote_name = self.git_branch.remote_name
587 self.branch_name = self.git_branch.branch_name[len(self.remote_name) + 1:]
588
589 def delete(self):
590 try:
591 git.push(self.remote_name, ':{0}'.format(self.branch_name))
592 except ErrorReturnCode as e:
593 raise GlError(stderr(e))
594
595 @property
596 def target(self):
597 """Object Id of the commit this branch points to."""
598 self._update()
599 return self.git_branch.target
600
601 @property
602 def head(self):
603 self._update()
604 return self.git_branch.peel()
605
606 def history(self, reverse=False):
607 return walker(self.gl_repo.git_repo, self.target, reverse=reverse)
608
609 def _update(self):
610 git.fetch(self.remote_name, self.branch_name)
611 self.git_branch = self.gl_repo.git_repo.lookup_branch(
612 self.remote_name + '/' + self.branch_name, pygit2.GIT_BRANCH_REMOTE)
613
614 def __str__(self):
615 return self.remote_name + '/' + self.branch_name
616
617
618class Branch(object):

Callers 2

lookup_branchMethod · 0.85
upstreamMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected