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

getRoot() public method

Find the root of a directory in a Git repository.
public getRoot ( string | null $dir = null, boolean $mustRun = false ) : string | false
$dir string | null
$mustRun boolean
return string | false
    public function getRoot($dir = null, $mustRun = false)
    {
        return $this->execute(['rev-parse', '--show-toplevel'], $dir, $mustRun);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Test GitHelper::isRepository().
  */
 public function testGetRoot()
 {
     $this->assertFalse($this->gitHelper->getRoot($this->tempDir));
     $repositoryDir = $this->getRepositoryDir();
     $this->assertEquals($repositoryDir, $this->gitHelper->getRoot($repositoryDir));
     mkdir($repositoryDir . '/1/2/3/4/5', 0755, true);
     $this->assertEquals($repositoryDir, $this->gitHelper->getRoot($repositoryDir . '/1/2/3/4/5'));
     $this->setExpectedException('Exception', 'Not a git repository');
     $this->gitHelper->getRoot($this->tempDir, true);
 }
All Usage Examples Of Platformsh\Cli\Helper\GitHelper::getRoot