Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Package.php

function Package::setSourceDistReferences

@inheritDoc

Overrides PackageInterface::setSourceDistReferences

File

vendor/composer/composer/src/Composer/Package/Package.php, line 645

Class

Package
Core package definitions that are needed to resolve dependencies and install packages

Namespace

Composer\Package

Code

public function setSourceDistReferences(string $reference) : void {
    $this->setSourceReference($reference);
    // only bitbucket, github and gitlab have auto generated dist URLs that easily allow replacing the reference in the dist URL
    // TODO generalize this a bit for self-managed/on-prem versions? Some kind of replace token in dist urls which allow this?
    if ($this->getDistUrl() !== null && Preg::isMatch('{^https?://(?:(?:www\\.)?bitbucket\\.org|(api\\.)?github\\.com|(?:www\\.)?gitlab\\.com)/}i', $this->getDistUrl())) {
        $this->setDistReference($reference);
        $this->setDistUrl(Preg::replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
    }
    elseif ($this->getDistReference()) {
        // update the dist reference if there was one, but if none was provided ignore it
        $this->setDistReference($reference);
    }
}
RSS feed
Powered by Drupal