Liip\RMT\VCS\Git::getCurrentBranch PHP Method

getCurrentBranch() public method

public getCurrentBranch ( )
    public function getCurrentBranch()
    {
        $branches = $this->executeGitCommand('branch');
        foreach ($branches as $branch) {
            if (strpos($branch, '* ') === 0 && !preg_match('/^\\*\\s\\(.*\\)$/', $branch)) {
                return substr($branch, 2);
            }
        }
        throw new \Liip\RMT\Exception('Not currently on any branch');
    }

Usage Example

Beispiel #1
0
 /**
  * @expectedException \Liip\RMT\Exception
  * @expectedExceptionMessage Not currently on any branch
  */
 public function testGetCurrentBranchWhenNotInBranch()
 {
     $vcs = new Git();
     exec("git checkout 9aca70b --quiet");
     $vcs->getCurrentBranch();
 }
All Usage Examples Of Liip\RMT\VCS\Git::getCurrentBranch