You are here

protected function ManageGitIgnore::managementOfGitIgnoreEnabled in Drupal 9

Same name and namespace in other branches
  1. 8 composer/Plugin/Scaffold/ManageGitIgnore.php \Drupal\Composer\Plugin\Scaffold\ManageGitIgnore::managementOfGitIgnoreEnabled()

Determines whether we should manage gitignore files.

Parameters

\Drupal\Composer\Plugin\Scaffold\ScaffoldOptions $options: Configuration options from the composer.json extras section.

Return value

bool Whether or not gitignore files should be managed.

1 call to ManageGitIgnore::managementOfGitIgnoreEnabled()
ManageGitIgnore::manageIgnored in composer/Plugin/Scaffold/ManageGitIgnore.php
Manages gitignore files.

File

composer/Plugin/Scaffold/ManageGitIgnore.php, line 83

Class

ManageGitIgnore
Manage the .gitignore file.

Namespace

Drupal\Composer\Plugin\Scaffold

Code

protected function managementOfGitIgnoreEnabled(ScaffoldOptions $options) {

  // If the composer.json stipulates whether gitignore is managed or not, then
  // follow its recommendation.
  if ($options
    ->hasGitIgnore()) {
    return $options
      ->gitIgnore();
  }

  // Do not manage .gitignore if there is no repository here.
  if (!Git::isRepository($this->io, $this->dir)) {
    return FALSE;
  }

  // If the composer.json did not specify whether or not .gitignore files
  // should be managed, then manage them if the vendor directory is ignored.
  return Git::checkIgnore($this->io, 'vendor', $this->dir);
}