getRoot() публичный Метод

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
Результат string | false
Пример #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);
 }
Пример #2
0
 /**
  * Create a default .gitignore file for the app.
  *
  * @param string $source The path to a default .gitignore file, relative to
  *                       the 'resources' directory.
  */
 protected function copyGitIgnore($source)
 {
     $source = CLI_ROOT . '/resources/' . $source;
     $gitRoot = $this->gitHelper->getRoot($this->appRoot);
     if (!$gitRoot) {
         return;
     }
     $appGitIgnore = $this->appRoot . '/.gitignore';
     if (!file_exists($appGitIgnore) && !file_exists($gitRoot . '/.gitignore')) {
         $this->output->writeln("Creating a .gitignore file");
         copy($source, $appGitIgnore);
     }
 }