function Git::isRepository

Same name in other branches
  1. 9 composer/Plugin/Scaffold/Git.php \Drupal\Composer\Plugin\Scaffold\Git::isRepository()
  2. 8.9.x composer/Plugin/Scaffold/Git.php \Drupal\Composer\Plugin\Scaffold\Git::isRepository()
  3. 11.x composer/Plugin/Scaffold/Git.php \Drupal\Composer\Plugin\Scaffold\Git::isRepository()

Checks to see if the project root dir is in a git repository.

Parameters

\Composer\IO\IOInterface $io: The Composer IO interface.

string $dir: Base directory for git process.

Return value

bool True if this is a repository.

1 call to Git::isRepository()
ManageGitIgnore::managementOfGitIgnoreEnabled in composer/Plugin/Scaffold/ManageGitIgnore.php
Determines whether we should manage gitignore files.

File

composer/Plugin/Scaffold/Git.php, line 74

Class

Git
Provide some Git utility operations.

Namespace

Drupal\Composer\Plugin\Scaffold

Code

public static function isRepository(IOInterface $io, $dir = NULL) {
    $process = new ProcessExecutor($io);
    $output = '';
    $exitCode = $process->execute('git rev-parse --show-toplevel', $output, $dir);
    return $exitCode == 0;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.