Platformsh\Cli\Helper\GitHelper::getCurrentBranch PHP Method

getCurrentBranch() public method

Get the current branch name.
public getCurrentBranch ( string $dir = null, boolean $mustRun = false ) : string | false
$dir string The path to a Git repository.
$mustRun boolean Enable exceptions if the Git command fails.
return string | false
    public function getCurrentBranch($dir = null, $mustRun = false)
    {
        $args = ['symbolic-ref', '--short', 'HEAD'];
        return $this->execute($args, $dir, $mustRun);
    }

Usage Example

 /**
  * Test GitHelper::getCurrentBranch().
  */
 public function testGetCurrentBranch()
 {
     $this->gitHelper->checkOutNew('test');
     $this->assertEquals('test', $this->gitHelper->getCurrentBranch());
 }
All Usage Examples Of Platformsh\Cli\Helper\GitHelper::getCurrentBranch