Skip to content

Commit 3f2c3c5

Browse files
committed
Fix TarantoolVersionRequirement to support the new versioning scheme
See tarantool/tarantool#6182. See tarantool-php/client#79.
1 parent 4830cf8 commit 3f2c3c5

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Annotation/Requirement/TarantoolVersionRequirement.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getName() : string
3636

3737
public function check(string $value) : ?string
3838
{
39-
// replace dash with dot
39+
// Replace dash with dot.
4040
$constraints = preg_replace('/(\d+\.\d+\.\d+)-(\d+)/', '$1.$2', $value);
4141

4242
if (Semver::satisfies($this->getVersion(), $constraints)) {
@@ -53,9 +53,14 @@ private function getVersion() : string
5353
}
5454

5555
$version = $this->client->call('box.info')[0]['version'];
56-
// normalize 2.2.1-3-g878e2a42c to 2.2.1.3
56+
57+
// Normalize 2.2.1-3-g878e2a42c to 2.2.1.3.
5758
$version = preg_replace('/-(\d+)-[^-]+$/', '.$1', $version);
5859

60+
// Treat "entrypoint" versions as "dev",
61+
// so 2.11.0-entrypoint.8 becomes 2.11.0-dev+entrypoint.8.
62+
$version = preg_replace('/(\d)-entrypoint/', '$1-dev+entrypoint', $version);
63+
5964
return $this->version = $version;
6065
}
6166
}

tests/Annotation/Requirement/TarantoolVersionRequirementTest.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ public function provideCheckPassesForValidConstraintsData() : iterable
8383
[$v2_3_1_3, '< 2.3.2'],
8484
[$v2_3_1_3, '< 2.4'],
8585
[$v2_3_1_3, '< 3'],
86+
87+
// @see https://github.com/tarantool/tarantool/discussions/6182
88+
['2.11.0-entrypoint', '< 2.11.0-alpha'],
89+
['2.11.0-entrypoint.8', '< 2.11.0-alpha'],
90+
['2.11.0-entrypoint.8', '< 2.11.1'],
91+
['2.11.0-entrypoint', '= 2.11.0-dev'],
92+
['2.11.0-entrypoint.8', '= 2.11.0-dev'],
93+
['2.11.0-entrypoint.8-g878e2a42c', '= 2.11.0-dev'],
94+
['2.11.0-entrypoint-17-g878e2a42c-dev', '= 2.11.0-dev'],
8695
];
8796
}
8897

@@ -93,7 +102,7 @@ public function testCheckFailsForInvalidConstraints(string $serverVersion, strin
93102
{
94103
$mockClient = $this->getTestDoubleClientBuilder()
95104
->shouldHandle(
96-
new CallRequest('box.info'), // $this->logicalOr()
105+
new CallRequest('box.info'),
97106
TestDoubleFactory::createResponseFromData([['version' => $serverVersion]]))
98107
->build();
99108

0 commit comments

Comments
 (0)