فهرست منبع

Add 'dev' flag to version parser

Jordi Boggiano 13 سال پیش
والد
کامیت
d6ae5ddf35
2فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 3 2
      src/Composer/Package/BasePackage.php
  2. 1 0
      src/Composer/Package/LinkConstraint/VersionConstraint.php

+ 3 - 2
src/Composer/Package/BasePackage.php

@@ -142,14 +142,14 @@ abstract class BasePackage implements PackageInterface
     }
 
     /**
-     * Parses a version string and returns an array with the version and its type (dev, alpha, beta, RC, stable)
+     * Parses a version string and returns an array with the version, its type (alpha, beta, RC, stable) and a dev flag (for development branches tracking)
      *
      * @param string $version
      * @return array
      */
     public static function parseVersion($version)
     {
-        if (!preg_match('#^v?(\d+)(\.\d+)?(\.\d+)?-?((?:beta|RC\d+|alpha|dev)\d*)?$#i', $version, $matches)) {
+        if (!preg_match('#^v?(\d+)(\.\d+)?(\.\d+)?-?((?:beta|RC\d+|alpha)\d*)?-?(dev)?$#i', $version, $matches)) {
             throw new \UnexpectedValueException('Invalid version string '.$version);
         }
 
@@ -158,6 +158,7 @@ abstract class BasePackage implements PackageInterface
                 .(!empty($matches[2]) ? $matches[2] : '.0')
                 .(!empty($matches[3]) ? $matches[3] : '.0'),
             'type' => strtolower(!empty($matches[4]) ? $matches[4] : 'stable'),
+            'dev' => !empty($matches[5]),
         );
     }
 }

+ 1 - 0
src/Composer/Package/LinkConstraint/VersionConstraint.php

@@ -33,6 +33,7 @@ class VersionConstraint extends SpecificConstraint
     public function __construct($operator, $version)
     {
         // TODO add third parameter releaseType and match that too
+        // TODO add fourth parameter devSnapshot and match that too
         $this->operator = $operator;
         $this->version = $version;
     }