public function branchExists($branchName, $dir = null, $mustRun = false)
    {
        // The porcelain command 'git branch' is less strict about character
        // encoding than (otherwise simpler) plumbing commands such as
        // 'git show-ref'.
        $result = $this->execute(['branch', '--list', '--no-color', '--no-column'], $dir, $mustRun);
        $branches = array_map(function ($line) {
            return trim(ltrim($line, '* '));
        }, explode("\n", $result));

        return in_array($branchName, $branches, true);
    }
public function branchExists($branchName, $dir = null, $mustRun = false)
    {
        // The porcelain command 'git branch' is less strict about character
        // encoding than (otherwise simpler) plumbing commands such as
        // 'git show-ref'.
        $result = $this->execute(['branch', '--list', '--no-color', '--no-column'], $dir, $mustRun);
        $branches = array_map(function ($line) {
            return trim(ltrim($line, '* '));
        }, explode("\n", $result));

        return in_array($branchName, $branches, true);
    }
public function branchExists ( $ branchName , $ dir = null , $ mustRun = false ) { // The porcelain command 'git branch' is less strict about character // encoding than (otherwise simpler) plumbing commands such as // 'git show-ref'. $ result = $ this -> execute ( [ 'branch' , '--list' , '--no-color' , '--no-column' ] , $ dir , $ mustRun ) ; $ branches = array_map ( function ( $ line ) { return trim ( ltrim ( $ line , '* ' ) ) ; } , explode ( "\n" , $ result ) ) ; return in_array ( $ branchName , $ branches , true ) ; }
Check whether a branch exists.

@param string $branchName
The branch name.
@param string $dir
The path to a Git repository.
@param bool   $mustRun
Enable exceptions if the Git command fails.

@return bool
Check whether a branch exists .