Get normalized branch name

It will return an empty result if it's not valid

@param string $branch
@return bool
547940
protected function validateBranch($branch)
    {
        try {
            if (!strpos($branch, '/')) {
                return false;
            }
            return $this->versionParser->normalizeBranch(
                $this->_getBranchWithoutNamespace($branch)
            );
        } catch (\Exception $e) {
            return false;
        }
    }
610905
public function pull($remote = null, $branch = null)
    {
        $result = $this->command . ' pull ' . $remote . ' ' . $branch;
        return $result;
    }
564205
public function getFirstChild(Branch $branch = null)
    {
        if (null === $branch) {
            return null;
        }

        //reset return first child or false if is not found
        $children = $branch->getChildren();
        $first = reset($children);

        return $first ? $first : null;
    }
1130766
public function getClientId()
    {
        preg_match('#branch\/(\d+)/#', $this->url, $matches);

        return isset($matches[1]) ? (int) $matches[1] : null;
    }
578395
public function getLastChild(Branch $branch = null)
    {
        if (null === $branch) {
            return null;
        }

        //end return last child or false if is not found
        $children = $branch->getChildren();
        $last = end($children);

        return $last ? $last : null;
    }
681891
public function normalizeOptionName($key) {
    if ($key === null) { return null; }
    $map = $this->getNormAlizedOptiOnnameMap();
    return isset($map[$key]) ? $map[$key] : null;
  }
1205423
public function getBranch(string $name)
    {
        /** @var Branch $branch */
        foreach ($this->getBranches() as $branch) {
            if ($branch->getName() === $name) {
                return $branch;
            }
        }

        return null;
    }
525883
protected function hasGitBranch($branch_name)
    {
        $task = $this->getGitBuildStack()
            ->exec("rev-parse -q --verify {$branch_name}");

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

        return !empty($result->getMessage());
    }
485749
protected function collectBranch() : string
    {
        $branchesResult = $this->executor->execute('git branch');

        foreach ($branchesResult as $result) {
            if (strpos($result, '* ') === 0) {
                $exploded = explode('* ', $result, 2);

                return $exploded[1];
            }
        }

        throw new \RuntimeException();
    }
422529
protected function optimizeBranchesHead(array &$branches)
	{
		// Capture common output
		$before = $this->optimizeBranchesOutput($branches, 'head');

		// Move the branch output to the tail for branches that have no body
		foreach ($branches as &$branch)
		{
			if ($branch['body'] !== '' || !empty($branch['tail']))
			{
				continue;
			}

			$branch['tail'] = array_reverse($branch['head']);
			$branch['head'] = [];
		}
		unset($branch);

		return $before;
	}
78103
public function getLangName( $lang = false ) {
		$lang = $lang ? $this->normalizeLang( $lang ) : $this->getLang();
		return $this->getLangNames()[$lang] ?? '';
	}
935488
protected static function getBranchesPassthrough(array $branches)
	{
		$values = [];
		foreach ($branches as $branch)
		{
			$values[] = $branch['passthrough'];
		}

		// If the last branch isn't an "else", we act as if there was an additional branch with no
		// passthrough
		if ($branch['statement'] !== 'else')
		{
			$values[] = 0;
		}

		return array_unique($values);
	}
987683
def _get_branch(repo, name):
    '''
    
    '''
    try:
        return [x for x in _all_branches(repo) if x[0] == name][0]
    except IndexError:
        return False
323115
public function getBranch(string $branch): array
    {
        return $this->getApi()->request($this->getApi()
                                             ->sprintf('/repos/:owner/:repo/branches/:branch', $this->getOwner(),
                                                 $this->getRepo(), $branch));
    }
641605
def current_branch(self):
        """"""
        branch_name = git(self.gitdir, self.gitwd, "symbolic-ref", "HEAD")
        return branch_name.replace('refs/heads/', '').strip()
843375
public function getCurrentBranch() {
        $output = $this->cmd('branch');

        foreach (explode("\n", $this->cmd('branch')) as $branchLine) {
            if ('*' === $branchLine{0}) {
                return substr($branchLine, 2);
            }
        }
    }
48914
public function getBranches()
    {
        $branches = array();

        $xml = $this->execute('branch');

        foreach ($xml->branch as $xmlBranch) {
            $branch = new BranchSummary;
            $branch->setName(self::normalise($xmlBranch->name, 'string'));
            $branch->setFirmId(self::normalise($xmlBranch->firmid, 'int'));
            $branch->setBranchId(self::normalise($xmlBranch->branchid, 'int'));
            $branch->setUrl(self::normalise($xmlBranch->url, 'string'));
            $branches[] = $branch;
        }

        return $branches;
    }