Print error and exit if *branch_name* is not the current branch.

    Args:
        branch_name (str):
            The supposed name of the current branch.
765603
def assert_on_branch(branch_name):
    # type: (str) -> None
    
    branch = git.current_branch(refresh=True)

    if branch.name != branch_name:
        if context.get('pretend', False):
            log.info("Would assert that you're on a <33>{}<32> branch",
                     branch_name)
        else:
            log.err("You're not on a <33>{}<31> branch!", branch_name)
            sys.exit(1)
558812
def patch_branch
      num = 1
      branch_name = form_data['title'].parameterize
      return branch_name unless branch_exists?(branch_name)
      branch = "#{branch_name}-#{num}"
      while branch_exists?(branch)
        num += 1
        branch = "#{branch_name}-#{num}"
      end
      branch
    end
1284928
def for_branch(self, branch):
        
        if self.org is None and branch is not None:
            raise InvalidKeyError(self.__class__, "Branches must have full library ids not just versions")
        return self.replace(branch=branch, version_guid=None)
655517
def frigg(branch: str):
    
    assert os.environ.get('FRIGG_BUILD_BRANCH') == branch
    assert not os.environ.get('FRIGG_PULL_REQUEST')
137207
def cleanup_branch(self, branch):
        
        set_state(WORKFLOW_STATES.REMOVING_BACKPORT_BRANCH)
        self.checkout_default_branch()
        try:
            self.delete_branch(branch)
        except subprocess.CalledProcessError:
            click.echo(f"branch {branch} NOT deleted.")
            set_state(WORKFLOW_STATES.REMOVING_BACKPORT_BRANCH_FAILED)
        else:
            click.echo(f"branch {branch} has been deleted.")
            set_state(WORKFLOW_STATES.REMOVED_BACKPORT_BRANCH)
1363840
public boolean isLocalBranch(final Git git, final String branch) {
        try {
            final List<Ref> refs = git.branchList().call();
            return refs.stream()
                .anyMatch(ref -> ref.getName().endsWith(branch));
        } catch (GitAPIException e) {
            throw new IllegalStateException(e);
        }
    }
725355
public static boolean branchExists(String branch, String baseUrl) {
        CommandLine cmdLine = new CommandLine(SVN_CMD);
        cmdLine.addArgument(CMD_LOG);
        cmdLine.addArgument(OPT_XML);
        addDefaultArguments(cmdLine, null, null);
        cmdLine.addArgument("-r");
        cmdLine.addArgument("HEAD:HEAD");
        cmdLine.addArgument(baseUrl + branch);

        try (InputStream inStr = ExecutionHelper.getCommandResult(cmdLine, new File("."), 0, 120000)) {
            return true;
        } catch (IOException e) {
            log.log(Level.FINE, "Branch " + branch + " not found or other error", e);
            return false;
        }
    }
1166428
def delete_branch(branch, path = Dir.pwd, opts = { :force => false })
      g = MiniGit.new(path)
      error "'#{branch}' is not a valid existing branch" unless list_branch(path).include?( branch )
      g.branch ((opts[:force]) ? :D : :d) => branch.to_s
    end
395043
def version_from_branch(branch):
    
    try:
        return tuple(
            map(
                int,
                re.match(r"^.*(?P<version>\d+(\.\d+)+).*$", branch)
                .groupdict()["version"]
                .split("."),
            )
        )
    except AttributeError as attr_err:
        raise ValueError(
            f"Branch {branch} seems to not have a version in its name."
        ) from attr_err
954227
def git_checkout(branch_name, create=False):
    # type: (str, bool) -> None
    
    log.info("Checking out <33>{}".format(branch_name))
    shell.run('git checkout {} {}'.format('-b' if create else '', branch_name))
630435
def get_current_branch(self) -> str:
        
        current_branch: str = self.repo.active_branch.name
        LOGGER.debug('current branch: %s', current_branch)
        return current_branch
468268
def get_branch_by_id(self, branch_id):
        
        for branch in self.branches:
            if branch.branch_id == branch_id:
                return branch
        raise AssertionError("couldn't find branch '%s'" % branch_id)
525883
protected function hasGitBranch($branch_name)
    {
        $task = $this->getGitBuildStack()
            ->exec("rev-parse -q --verify {$branch_name}");

        $result = $this->runSilentCommand($task);

        return !empty($result->getMessage());
    }
225660
def branch_type(cls, branch):
        
        typename = branch.GetClassName()
        if not typename:
            leaf = branch.GetListOfLeaves()[0]
            typename = leaf.GetTypeName()
            # check if leaf has multiple elements
            leaf_count = leaf.GetLeafCount()
            if leaf_count:
                length = leaf_count.GetMaximum()
            else:
                length = leaf.GetLen()
            if length > 1:
                typename = '{0}[{1:d}]'.format(typename, length)
        return typename
757271
def get_git_branch(git_path='git'):
    
    branch_match = call((git_path, 'rev-parse', '--symbolic-full-name', 'HEAD'))
    if branch_match == "HEAD":
        return None
    else:
        return os.path.basename(branch_match)
1334694
def fetch(self, remote, branch, local_branch = None, force=False):
        '''
        '''
        pb = ProgressBar()
        pb.setup(self.name)

        if local_branch:
            branch = ':'.join([branch, local_branch])

        remote.fetch(branch, update_head_ok=True, force=force, progress=pb)
        print()
918344
def msg(cls, error=None, debug=True, trace=True):
        
        if debug and error is not None:
            print(error)
        # TODO: BUG: trace should only be printed if debug is true
        if trace:
            print(traceback.format_exc())