Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#11917 fix: Possibility to handle long URLs #11918

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Composer/Downloader/GitDownloader.php
Expand Up @@ -67,7 +67,7 @@ protected function doDownload(PackageInterface $package, string $path, string $u

GitUtil::cleanEnv();

$cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
$cachePath = $this->config->get('cache-vcs-dir').'/'.md5($url).'/';
$gitVersion = GitUtil::getVersion($this->process);

// --dissociate option is only available since git 2.3.0-rc0
Expand All @@ -92,7 +92,7 @@ protected function doInstall(PackageInterface $package, string $path, string $ur
{
GitUtil::cleanEnv();
$path = $this->normalizePath($path);
$cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
$cachePath = $this->config->get('cache-vcs-dir').'/'.md5($url).'/';
$ref = $package->getSourceReference();
$flag = Platform::isWindows() ? '/D ' : '';

Expand Down Expand Up @@ -161,7 +161,7 @@ protected function doUpdate(PackageInterface $initial, PackageInterface $target,
throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
}

$cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
$cachePath = $this->config->get('cache-vcs-dir').'/'.md5($url).'/';
$ref = $target->getSourceReference();

if (!empty($this->cachedPackages[$target->getId()][$ref])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Repository/Vcs/GitDriver.php
Expand Up @@ -52,7 +52,7 @@ public function initialize(): void
throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
}

$this->repoDir = $this->config->get('cache-vcs-dir') . '/' . Preg::replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
$this->repoDir = $this->config->get('cache-vcs-dir') . '/' . md5($this->url) . '/';

GitUtil::cleanEnv();

Expand Down
2 changes: 1 addition & 1 deletion tests/Composer/Test/Downloader/GitDownloaderTest.php
Expand Up @@ -155,7 +155,7 @@ public function testDownloadWithCache(): void

$config = new Config;
$this->setupConfig($config);
$cachePath = $config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', 'https://example.com/composer/composer').'/';
$cachePath = $config->get('cache-vcs-dir').'/'.md5('https://example.com/composer/composer').'/';

$filesystem = new \Composer\Util\Filesystem;
$filesystem->removeDirectory($cachePath);
Expand Down
2 changes: 1 addition & 1 deletion tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php
Expand Up @@ -304,7 +304,7 @@ public function testPrivateRepositoryNoInteraction(): void
$process = $this->getProcessExecutorMock();
$process->expects([
['cmd' => 'git config github.accesstoken', 'return' => 1],
'git clone --mirror -- '.ProcessExecutor::escape($repoSshUrl).' '.ProcessExecutor::escape($this->config->get('cache-vcs-dir').'/git-github.com-composer-packagist.git/'),
'git clone --mirror -- '.ProcessExecutor::escape($repoSshUrl).' '.ProcessExecutor::escape($this->config->get('cache-vcs-dir').'/'.md5($repoSshUrl).'/'),
[
'cmd' => 'git show-ref --tags --dereference',
'stdout' => $sha.' refs/tags/'.$identifier,
Expand Down