<commit_before><?php

namespace Composer\Repository;

use Composer\Repository\Vcs\VcsDriverInterface;
use Composer\Package\Version\VersionParser;
use Composer\Package\Loader\ArrayLoader;

/**
 * @author <NAME> <<EMAIL>>
 */
class VcsRepository extends ArrayRepository
{
    protected $url;
    protected $packageName;

    public function __construct(array $config)
    {
        if (!filter_var($config['url'], FILTER_VALIDATE_URL)) {
            throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$config['url']);
        }

        $this->url = $config['url'];
    }

    protected function initialize()
    {
        parent::initialize();

        $debug = false;

        $drivers = array(
            'Composer\Repository\Vcs\GitHubDriver',
            'Composer\Repository\Vcs\GitDriver',
            'Composer\Repository\Vcs\SvnDriver',
        );

        foreach ($drivers as $driver) {
            if ($driver::supports($this->url)) {
                $driver = new $driver($this->url);
                $driver->initialize();
                break;
            }
        }

        $versionParser = new VersionParser;
        $loader = new ArrayLoader($this->repositoryManager);
        $versions = array();

        if ($driver->hasComposerFile($driver->getRootIdentifier())) {
            $data = $driver->getComposerInformation($driver->getRootIdentifier());
            $this->packageName = !empty($data['name']) ? $data['name'] : null;
        }<commit_msg>Check we have a driver before using it<commit_after><?php

namespace Composer\Repository;

use Composer\Repository\Vcs\VcsDriverInterface;
use Composer\Package\Version\VersionParser;
use Composer\Package\Loader\ArrayLoader;

/**
 * @author <NAME> <<EMAIL>>
 */
class VcsRepository extends ArrayRepository
{
    protected $url;
    protected $packageName;

    public function __construct(array $config)
    {
        if (!filter_var($config['url'], FILTER_VALIDATE_URL)) {
            throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$config['url']);
        }

        $this->url = $config['url'];
    }

    protected function initialize()
    {
        parent::initialize();

        $debug = false;

        $drivers = array(
            'Composer\Repository\Vcs\GitHubDriver',
            'Composer\Repository\Vcs\GitDriver',
            'Composer\Repository\Vcs\SvnDriver',
        );

        foreach ($drivers as $driver) {
            if ($driver::supports($this->url)) {
                $driver = new $driver($this->url);
                $driver->initialize();
                break;
            }
        }

        if (!$driver) {
            throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
        }

        $versionParser = new VersionParser;
        $loader = new ArrayLoader($this->repositoryManager);
        $versions = array();

        if ($driver->hasComposerFile($driver->getRootIdentifier())) {
            $data = $driver->getComposerInformation($driver->getRootIdentifier());
            $this->packageName = !empty($data['name']) ? $data['name'] : null;
        }
{'fraction_non_alphanumeric': 0.1372115080619665, 'fraction_numerical': 0.0, 'mean_word_length': 2.446623093681917, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1874522', 'n_tokens_mistral': 872, 'n_tokens_neox': 839, 'n_words': 171}