Browse Source

Remove old code

Jordi Boggiano 13 năm trước cách đây
mục cha
commit
90e70e5eea

+ 0 - 20
src/Packagist/WebBundle/Repository/Provider/GitHubProvider.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace Packagist\WebBundle\Repository\Provider;
-
-use Packagist\WebBundle\Repository\Repository\GitHubRepository;
-
-class GitHubProvider implements ProviderInterface
-{
-    public function getRepository($url)
-    {
-        if($this->supports($url)){
-            return new GitHubRepository($url);
-        }
-    }
-
-    public function supports($url)
-    {
-        return preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $url, $match);
-    }
-}

+ 0 - 21
src/Packagist/WebBundle/Repository/Provider/GitProvider.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace Packagist\WebBundle\Repository\Provider;
-
-use Packagist\WebBundle\Repository\Repository\GitRepository;
-
-class GitProvider implements ProviderInterface
-{
-    public function getRepository($url)
-    {
-        if($this->supports($url)){
-            return new GitRepository($url);
-        }
-    }
-
-    public function supports($url)
-    {
-        // TODO adjust
-        return preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $url, $match);
-    }
-}

+ 0 - 20
src/Packagist/WebBundle/Repository/Provider/ProviderInterface.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace Packagist\WebBundle\Repository\Provider;
-
-interface ProviderInterface
-{
-    /**
-     * Returns whether the provider supports the URL
-     * @param string $url
-     */
-    public function supports($url);
-
-    /**
-     * Get the repository for the URL.
-     * This method is expected to return null if the URL is not supported.
-     *
-     * @param string $url
-     */
-    public function getRepository($url);
-}

+ 0 - 144
src/Packagist/WebBundle/Repository/Repository/GitHubRepository.php

@@ -1,144 +0,0 @@
-<?php
-
-namespace Packagist\WebBundle\Repository\Repository;
-
-use Composer\Json\JsonFile;
-
-class GitHubRepository implements RepositoryInterface
-{
-    protected $owner;
-    protected $repository;
-    protected $repositoryData;
-    protected $tags;
-    protected $branches;
-    protected $infoCache = array();
-
-    public function __construct($url)
-    {
-        preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $url, $match);
-        $this->owner = $match[1];
-        $this->repository = $match[2];
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getType()
-    {
-        return 'git';
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getRootIdentifier()
-    {
-        return 'master';
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getUrl()
-    {
-        return 'http://github.com/'.$this->owner.'/'.$this->repository.'.git';
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getSource($identifier)
-    {
-        $label = array_search($identifier, (array) $this->tags) ?: $identifier;
-        return array('type' => $this->getType(), 'url' => $this->getUrl(), 'reference' => $label, 'shasum' => '');
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getDist($identifier)
-    {
-        $repoData = $this->getRepositoryData();
-        $attempts = 3;
-
-        while ($attempts--) {
-            $label = array_search($identifier, (array) $this->tags) ?: $identifier;
-            $url = 'https://github.com/'.$this->owner.'/'.$this->repository.'/zipball/'.$label;
-            if (!$checksum = @hash_file('sha1', $url)) {
-                continue;
-            }
-
-            return array('type' => 'zip', 'url' => $url, 'shasum' => $checksum, 'reference' => $label);
-        }
-
-        // TODO clone the repo and build/host a zip ourselves. Not sure if this can happen, but it'll be needed for non-GitHub repos anyway
-        throw new \LogicException('Could not retrieve dist file');
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getComposerInformation($identifier)
-    {
-        if (!isset($this->infoCache[$identifier])) {
-            $composer = @file_get_contents('https://raw.github.com/'.$this->owner.'/'.$this->repository.'/'.$identifier.'/composer.json');
-            if (!$composer) {
-                throw new \UnexpectedValueException('Failed to retrieve composer information for identifier '.$identifier.' in '.$this->getUrl());
-            }
-
-            $composer = JsonFile::parseJson($composer);
-
-            if (!isset($composer['time'])) {
-                $commit = json_decode(file_get_contents('http://github.com/api/v2/json/commits/show/'.$this->owner.'/'.$this->repository.'/'.$identifier), true);
-                $composer['time'] = $commit['commit']['committed_date'];
-            }
-            $this->infoCache[$identifier] = $composer;
-        }
-
-        return $this->infoCache[$identifier];
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getTags()
-    {
-        if (null === $this->tags) {
-            $tagsData = json_decode(file_get_contents('http://github.com/api/v2/json/repos/show/'.$this->owner.'/'.$this->repository.'/tags'), true);
-            $this->tags = $tagsData['tags'];
-        }
-        return $this->tags;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function getBranches()
-    {
-        if (null === $this->branches) {
-            $branchesData = json_decode(file_get_contents('http://github.com/api/v2/json/repos/show/'.$this->owner.'/'.$this->repository.'/branches'), true);
-            $this->branches = $branchesData['branches'];
-        }
-        return $this->branches;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public function hasComposerFile($identifier)
-    {
-        return (false !== @fopen('https://raw.github.com/'.$this->owner.'/'.$this->repository.'/'.$identifier.'/composer.json', 'r'));
-    }
-
-    protected function getRepositoryData()
-    {
-        if (null === $this->repositoryData) {
-            $url = 'http://github.com/api/v2/json/repos/show/'.$this->owner.'/'.$this->repository;
-            $this->repositoryData = json_decode(@file_get_contents($url), true);
-            if (!$this->repositoryData) {
-                throw new \UnexpectedValueException('Failed to download from '.$url);
-            }
-        }
-        return $this->repositoryData;
-    }
-}

+ 0 - 69
src/Packagist/WebBundle/Repository/Repository/RepositoryInterface.php

@@ -1,69 +0,0 @@
-<?php
-
-namespace Packagist\WebBundle\Repository\Repository;
-
-interface RepositoryInterface
-{
-    /**
-     * Return the composer.json file information
-     *
-     * @param string $identifier Any identifier to a specific branch/tag/commit
-     * @return array containing all infos from the composer.json file
-     */
-    function getComposerInformation($identifier);
-
-    /**
-     * Return the root identifier (trunk, master, ..)
-     *
-     * @return string Identifier
-     */
-    function getRootIdentifier();
-
-    /**
-     * Return list of branches in the repository
-     *
-     * @return array Branch names as keys, identifiers as values
-     */
-    function getBranches();
-
-    /**
-     * Return list of tags in the repository
-     *
-     * @return array Tag names as keys, identifiers as values
-     */
-    function getTags();
-
-    /**
-     * @param string $identifier Any identifier to a specific branch/tag/commit
-     * @return array With type, url, reference and shasum keys.
-     */
-    function getDist($identifier);
-
-    /**
-     * @param string $identifier Any identifier to a specific branch/tag/commit
-     * @return array With type, url, reference and shasum keys.
-     */
-    function getSource($identifier);
-
-    /**
-     * Return the URL of the repository
-     *
-     * @return string
-     */
-    function getUrl();
-
-    /**
-     * Return the type of the repository
-     *
-     * @return string
-     */
-    function getType();
-    /**
-     * Return true if the repository has a composer file for a given identifier,
-     * false otherwise.
-     *
-     * @param string $identifier Any identifier to a specific branch/tag/commit
-     * @return boolean Whether the repository has a composer file for a given identifier.
-     */
-    function hasComposerFile($identifier);
-}

+ 0 - 24
src/Packagist/WebBundle/Repository/RepositoryProvider.php

@@ -1,24 +0,0 @@
-<?php
-
-namespace Packagist\WebBundle\Repository;
-
-use Packagist\WebBundle\Repository\Provider\ProviderInterface;
-
-class RepositoryProvider implements RepositoryProviderInterface
-{
-    protected $providers = array();
-
-    public function addProvider(ProviderInterface $provider)
-    {
-        $this->providers[] = $provider;
-    }
-
-    public function getRepository($url)
-    {
-        foreach ($this->providers as $provider) {
-            if ($provider->supports($url)) {
-                return $provider->getRepository($url);
-            }
-        }
-    }
-}

+ 0 - 10
src/Packagist/WebBundle/Repository/RepositoryProviderInterface.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace Packagist\WebBundle\Repository;
-
-use Packagist\WebBundle\Repository\Provider\ProviderInterface;
-
-interface RepositoryProviderInterface
-{
-    public function getRepository($url);
-}