From 0b0b0dd24c1035be86653b53b8b6018aa087eb0e Mon Sep 17 00:00:00 2001 From: Uladzimir Tsykun Date: Sun, 15 Sep 2024 01:07:11 +0200 Subject: [PATCH] Fix SVN support --- src/Entity/Version.php | 14 ++++++++++++++ src/Package/Updater.php | 10 ++++++++++ src/Service/DistManager.php | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Entity/Version.php b/src/Entity/Version.php index 9a3784b3..02bb6b1a 100644 --- a/src/Entity/Version.php +++ b/src/Entity/Version.php @@ -414,6 +414,20 @@ public function getSource() return $this->source ? json_decode($this->source, true) : null; } + public function getSourceType(): ?string + { + $type = ($this->getSource()['type'] ?? null); + + return is_string($type) ? $type : null; + } + + public function getSourceReference(): ?string + { + $reference = $this->getSource()['reference'] ?? null; + + return is_string($reference) ? $reference : null; + } + /** * Set dist * diff --git a/src/Package/Updater.php b/src/Package/Updater.php index 61bf69b9..f879c7a4 100644 --- a/src/Package/Updater.php +++ b/src/Package/Updater.php @@ -584,6 +584,16 @@ private function updateArchive(PackageInterface $data, Package $package): ?array return null; } + // svn support + if ($data->getSourceType() === 'svn' && $data->getSourceReference()) { + $virtualReference = sha1($data->getSourceReference()); + return [ + 'url' => $this->distConfig->generateRoute($data->getName(), $virtualReference, $this->distConfig->getArchiveFormat()), + 'type' => $this->distConfig->getArchiveFormat(), + 'reference' => $virtualReference + ]; + } + if ($this->distConfig->isPreBuild()) { $path = null; try { diff --git a/src/Service/DistManager.php b/src/Service/DistManager.php index 1bf417de..dbc83f1c 100644 --- a/src/Service/DistManager.php +++ b/src/Service/DistManager.php @@ -213,7 +213,7 @@ private function downloadVCS(string $reference, Package $package, ?string $versi } $probe = $versionName ? $this->tryFromVersion($package, $versionName) : null; - if (null === $probe || $probe->getSourceReference() !== $reference) { + if (null === $probe || ($probe->getSourceReference() !== $reference && $probe->getSourceType() !== 'svn')) { $probe = $this->guessCompletePackage($reference, $repository->getPackages()); }