class Git

Same name in other branches
  1. 9 composer/Plugin/Scaffold/Git.php \Drupal\Composer\Plugin\Scaffold\Git
  2. 8.9.x composer/Plugin/Scaffold/Git.php \Drupal\Composer\Plugin\Scaffold\Git
  3. 10 composer/Plugin/Scaffold/Git.php \Drupal\Composer\Plugin\Scaffold\Git

Provide some Git utility operations.

@internal

Hierarchy

  • class \Drupal\Composer\Plugin\Scaffold\Git

Expanded class hierarchy of Git

6 string references to 'Git'
Fixtures::composerLock in core/tests/Drupal/Tests/Composer/Generator/Fixtures.php
Data for a composer.lock fixture.
GenerateThemeTest::testContribStarterkitDevSnapshotWithGitNotInstalled in core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php
Tests the generate-theme command on a theme with a dev version without git.
GenerateThemeTest::testContribStarterkitDevSnapshotWithGitNotInstalled in core/tests/Drupal/BuildTests/Command/GenerateThemeTest.php
Tests the generate-theme command on a theme with a dev version without git.
SecurityFileUploadEventSubscriberTest::provideFilenames in core/modules/system/tests/src/Unit/Event/SecurityFileUploadEventSubscriberTest.php
Provides data for testSanitizeName().
xa1.php in core/lib/Drupal/Component/Transliteration/data/xa1.php

... See full list

File

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

Namespace

Drupal\Composer\Plugin\Scaffold
View source
class Git {
    
    /**
     * This class provides only static methods.
     */
    private function __construct() {
    }
    
    /**
     * Determines whether the specified scaffold file is already ignored.
     *
     * @param \Composer\IO\IOInterface $io
     *   The Composer IO interface.
     * @param string $path
     *   Path to scaffold file to check.
     * @param string $dir
     *   Base directory for git process.
     *
     * @return bool
     *   Whether the specified file is already ignored or not (TRUE if ignored).
     */
    public static function checkIgnore(IOInterface $io, $path, $dir = NULL) {
        $process = new ProcessExecutor($io);
        $output = '';
        $exitCode = $process->execute('git check-ignore ' . $process->escape($path), $output, $dir);
        return $exitCode == 0;
    }
    
    /**
     * Determines whether the specified scaffold file is tracked by git.
     *
     * @param \Composer\IO\IOInterface $io
     *   The Composer IO interface.
     * @param string $path
     *   Path to scaffold file to check.
     * @param string $dir
     *   Base directory for git process.
     *
     * @return bool
     *   Whether the specified file is already tracked or not (TRUE if tracked).
     */
    public static function checkTracked(IOInterface $io, $path, $dir = NULL) {
        $process = new ProcessExecutor($io);
        $output = '';
        $exitCode = $process->execute('git ls-files --error-unmatch ' . $process->escape($path), $output, $dir);
        return $exitCode == 0;
    }
    
    /**
     * Checks to see if the project root dir is in a git repository.
     *
     * @param \Composer\IO\IOInterface $io
     *   The Composer IO interface.
     * @param string $dir
     *   Base directory for git process.
     *
     * @return bool
     *   True if this is a repository.
     */
    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;
    }

}

Members

Title Sort descending Modifiers Object type Summary
Git::checkIgnore public static function Determines whether the specified scaffold file is already ignored.
Git::checkTracked public static function Determines whether the specified scaffold file is tracked by git.
Git::isRepository public static function Checks to see if the project root dir is in a git repository.
Git::__construct private function This class provides only static methods.

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