Skip to content

Commit 247614a

Browse files
committed
Support 7.x-1.x version constraint
1 parent 8dfd1c2 commit 247614a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

spec/Drupal/ParseComposer/InfoFileSpec.php

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function it_understands_operators_in_constraints()
4848

4949
$this->constraint('bar (1.0)')->shouldReturn(['drupal/bar' => '7.1.0']);
5050
$this->constraint('bar (1.x)')->shouldReturn(['drupal/bar' => '7.1.*']);
51+
$this->constraint('bar (7.x-1.x)')->shouldReturn(['drupal/bar' => '7.1.*']);
5152
$this->constraint('bar (>=1.x)')->shouldReturn(['drupal/bar' => '>=7.1.0']);
5253
$this->constraint('bar (>= 1.x)')->shouldReturn(['drupal/bar' => '>=7.1.0']);
5354
$this->constraint('bar (>1.0, <=3.2, !=3.0)')->shouldReturn(['drupal/bar' => '>7.1.0, <=7.3.2, !=7.3.0']);

src/InfoFile.php

+13
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public function constraint($dependency)
139139
);
140140
list($all, $symbols, $version) = $matches;
141141

142+
// Version: 1.x, > 1.x
142143
preg_match('/^([0-9]+)\.x$/', $version, $matches);
143144
if (!empty($matches)) {
144145
$version = $matches[1];
@@ -150,6 +151,18 @@ public function constraint($dependency)
150151
continue;
151152
}
152153

154+
// Version: 7.x-1.x, > 7.x-1.x
155+
preg_match('/^([0-9]+)\.x-([0-9]+)\.x$/', $version, $matches);
156+
if (!empty($matches)) {
157+
$version = $matches[2];
158+
if (empty($symbols)) {
159+
$constraints[] = $symbols.$this->core.'.'.$version.'.*';
160+
} else {
161+
$constraints[] = $symbols.$this->core.'.'.$version.'.0';
162+
}
163+
continue;
164+
}
165+
153166
$versionString = $this->versionFactory
154167
->create([$this->core, $version], $this->isCoreComponent($project))
155168
->getSemVer();

0 commit comments

Comments
 (0)