Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HgDriver.php

function HgDriver::supports

@inheritDoc

Overrides VcsDriverInterface::supports

File

vendor/composer/composer/src/Composer/Repository/Vcs/HgDriver.php, line 213

Class

HgDriver
@author Per Bernhardt <plb@webfactory.de>

Namespace

Composer\Repository\Vcs

Code

public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false) : bool {
    if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\\.kilnhg.com)#i', $url)) {
        return true;
    }
    // local filesystem
    if (Filesystem::isLocalPath($url)) {
        $url = Filesystem::getPlatformPath($url);
        if (!is_dir($url)) {
            return false;
        }
        $process = new ProcessExecutor($io);
        // check whether there is a hg repo in that path
        if ($process->execute([
            'hg',
            'summary',
        ], $output, $url) === 0) {
            return true;
        }
    }
    if (!$deep) {
        return false;
    }
    $process = new ProcessExecutor($io);
    $exit = $process->execute([
        'hg',
        'identify',
        '--',
        $url,
    ], $ignored);
    return $exit === 0;
}
RSS feed
Powered by Drupal