From f48634d074a48c20cf5555c4f44ccf256362fb7b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 29 Sep 2011 00:49:23 +0200 Subject: [PATCH] Add source/dist reference information to package --- src/Composer/Package/Loader/ArrayLoader.php | 2 ++ src/Composer/Package/MemoryPackage.php | 34 +++++++++++++++++++++ src/Composer/Package/PackageInterface.php | 14 +++++++++ 3 files changed, 50 insertions(+) diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 69d67b5e3..146522ec3 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -65,6 +65,7 @@ class ArrayLoader } $package->setSourceType($config['source']['type']); $package->setSourceUrl($config['source']['url']); + $package->setSourceReference($config['source']['reference']); } if (isset($config['dist'])) { @@ -79,6 +80,7 @@ class ArrayLoader } $package->setDistType($config['dist']['type']); $package->setDistUrl($config['dist']['url']); + $package->setDistReference($config['dist']['reference']); $package->setDistSha1Checksum($config['dist']['shasum']); } diff --git a/src/Composer/Package/MemoryPackage.php b/src/Composer/Package/MemoryPackage.php index 535b73eb1..eb9f644fd 100644 --- a/src/Composer/Package/MemoryPackage.php +++ b/src/Composer/Package/MemoryPackage.php @@ -23,8 +23,10 @@ class MemoryPackage extends BasePackage protected $installationSource; protected $sourceType; protected $sourceUrl; + protected $sourceReference; protected $distType; protected $distUrl; + protected $distReference; protected $distSha1Checksum; protected $releaseType; protected $version; @@ -133,6 +135,22 @@ class MemoryPackage extends BasePackage return $this->sourceUrl; } + /** + * @param string $reference + */ + public function setSourceReference($reference) + { + $this->sourceReference = $reference; + } + + /** + * {@inheritDoc} + */ + public function getSourceReference() + { + return $this->sourceReference; + } + /** * @param string $type */ @@ -165,6 +183,22 @@ class MemoryPackage extends BasePackage return $this->distUrl; } + /** + * @param string $reference + */ + public function setDistReference($reference) + { + $this->distReference = $reference; + } + + /** + * {@inheritDoc} + */ + public function getDistReference() + { + return $this->distReference; + } + /** * @param string $url */ diff --git a/src/Composer/Package/PackageInterface.php b/src/Composer/Package/PackageInterface.php index ed7c08bf4..54750d907 100644 --- a/src/Composer/Package/PackageInterface.php +++ b/src/Composer/Package/PackageInterface.php @@ -110,6 +110,13 @@ interface PackageInterface */ function getSourceUrl(); + /** + * Returns the repository reference of this package, e.g. master, 1.0.0 or a commit hash for git + * + * @return string The repository reference + */ + function getSourceReference(); + /** * Returns the type of the distribution archive of this version, e.g. zip, tarball * @@ -124,6 +131,13 @@ interface PackageInterface */ function getDistUrl(); + /** + * Returns the reference of the distribution archive of this version, e.g. master, 1.0.0 or a commit hash for git + * + * @return string + */ + function getDistReference(); + /** * Returns the sha1 checksum for the distribution archive of this version *