<commit_before><?php

/*
 * This file is part of Composer.
 *
 * (c) <NAME> <<EMAIL>>
 *     <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer\Repository;

use Composer\Downloader\TransportException;
use Composer\Repository\Vcs\VcsDriverInterface;
use Composer\Package\Version\VersionParser;
use Composer\Package\Loader\ArrayLoader;
use Composer\IO\IOInterface;
use Composer\Config;

/**
 * @author <NAME> <<EMAIL>>
 */
class VcsRepository extends ArrayRepository
{
    protected $url;
    protected $packageName;
    protected $verbose;
    protected $io;
    protected $config;
    protected $versionParser;
    protected $type;

    public function __construct(array $repoConfig, IOInterface $io, Config $config, array $drivers = null)
    {
        $this->drivers = $drivers ?: array(
            'github'        => 'Composer\Repository\Vcs\GitHubDriver',
            'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
            'git'           => 'Composer\Repository\Vcs\GitDriver',
            'svn'           => 'Composer\Repository\Vcs\SvnDriver',
            'hg-bitbucket'  => 'Composer\Repository\Vcs\HgBitbucketDriver',
            'hg'            => 'Composer\Repository\Vcs\HgDriver',
        );

        $this->url = $repoConfig['url'];
        $this->io = $io;
        $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
        $this->verbose = $io->isVerbose();
        $this->config = $config;
    }

    public function getDriver()
    {
        if (isset($this->drivers[$this->type])) {
            $class = $this->drivers[$this->type];
            $driver = new $class($this->url, $this->io, $this->config);
            $driver->initialize();

            return $driver;
        }

        foreach ($this->drivers as $driver) {
            if ($driver::supports($this->io, $this->url)) {
                $driver = new $driver($this->url, $this->io, $this->config);
                $driver->initialize();

                return $driver;
            }
        }

        foreach ($this->drivers as $driver) {
            if ($driver::supports($this->io, $this->url, true)) {
                $driver = new $driver($this->url, $this->io, $this->config);
                $driver->initialize();

                return $driver;
            }
        }
    }

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

        $verbose = $this->verbose;

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

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

        try {
            if ($driver->hasComposerFile($driver->getRootIdentifier())) {
                $data = $driver->getComposerInformation($driver->getRootIdentifier());
                $this->packageName = !empty($data['name']) ? $data['name'] : null;
            }
        } catch (\Exception $e) {
            if ($verbose) {
                $this->io->write('Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage());
            }
        }

        foreach ($driver->getTags() as $tag => $identifier) {
            $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
            if ($verbose) {
                $this->io->write($msg);
            } else {
                $this->io->overwrite($msg, false);
            }

            if (!$parsedTag = $this->validateTag($tag)) {
                if ($verbose) {
                    $this->io->write('Skipped tag '.$tag.', invalid tag name');
                }
                continue;<commit_msg>Fix release- tags not being parsed<commit_after><?php

/*
 * This file is part of Composer.
 *
 * (c) <NAME> <<EMAIL>>
 *     <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer\Repository;

use Composer\Downloader\TransportException;
use Composer\Repository\Vcs\VcsDriverInterface;
use Composer\Package\Version\VersionParser;
use Composer\Package\Loader\ArrayLoader;
use Composer\IO\IOInterface;
use Composer\Config;

/**
 * @author <NAME> <<EMAIL>>
 */
class VcsRepository extends ArrayRepository
{
    protected $url;
    protected $packageName;
    protected $verbose;
    protected $io;
    protected $config;
    protected $versionParser;
    protected $type;

    public function __construct(array $repoConfig, IOInterface $io, Config $config, array $drivers = null)
    {
        $this->drivers = $drivers ?: array(
            'github'        => 'Composer\Repository\Vcs\GitHubDriver',
            'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
            'git'           => 'Composer\Repository\Vcs\GitDriver',
            'svn'           => 'Composer\Repository\Vcs\SvnDriver',
            'hg-bitbucket'  => 'Composer\Repository\Vcs\HgBitbucketDriver',
            'hg'            => 'Composer\Repository\Vcs\HgDriver',
        );

        $this->url = $repoConfig['url'];
        $this->io = $io;
        $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
        $this->verbose = $io->isVerbose();
        $this->config = $config;
    }

    public function getDriver()
    {
        if (isset($this->drivers[$this->type])) {
            $class = $this->drivers[$this->type];
            $driver = new $class($this->url, $this->io, $this->config);
            $driver->initialize();

            return $driver;
        }

        foreach ($this->drivers as $driver) {
            if ($driver::supports($this->io, $this->url)) {
                $driver = new $driver($this->url, $this->io, $this->config);
                $driver->initialize();

                return $driver;
            }
        }

        foreach ($this->drivers as $driver) {
            if ($driver::supports($this->io, $this->url, true)) {
                $driver = new $driver($this->url, $this->io, $this->config);
                $driver->initialize();

                return $driver;
            }
        }
    }

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

        $verbose = $this->verbose;

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

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

        try {
            if ($driver->hasComposerFile($driver->getRootIdentifier())) {
                $data = $driver->getComposerInformation($driver->getRootIdentifier());
                $this->packageName = !empty($data['name']) ? $data['name'] : null;
            }
        } catch (\Exception $e) {
            if ($verbose) {
                $this->io->write('Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage());
            }
        }

        foreach ($driver->getTags() as $tag => $identifier) {
            $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
            if ($verbose) {
                $this->io->write($msg);
            } else {
                $this->io->overwrite($msg, false);
            }

            // strip the release- prefix from tags if present
            $tag = str_replace('release-', '', $tag);

            if (!$parsedTag = $this->validateTag($tag)) {
                if ($verbose) {
                    $this->io->write('Skipped tag '.$tag.', invalid tag name');
                }
                continue;
{'fraction_non_alphanumeric': 0.15922998470168281, 'fraction_numerical': 0.0, 'mean_word_length': 2.0196304849884528, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 147, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2966814', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2171, 'n_words': 471}