Skip to content

Commit 3f0dc66

Browse files
Fix reading recipe version from lock file
1 parent 4345d08 commit 3f0dc66

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Command/RecipesCommand.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ private function displayPackageInformation(Recipe $recipe)
156156
$lockRepo = $recipeLock['recipe']['repo'] ?? null;
157157
$lockFiles = $recipeLock['files'] ?? null;
158158
$lockBranch = $recipeLock['recipe']['branch'] ?? null;
159+
$lockVersion = $recipeLock['recipe']['version'] ?? $recipeLock['version'] ?? null;
159160

160161
$status = '<comment>up to date</comment>';
161162
if ($recipe->isAuto()) {
@@ -174,7 +175,7 @@ private function displayPackageInformation(Recipe $recipe)
174175
$recipe->getName(),
175176
$lockRepo,
176177
$lockBranch ?? '',
177-
$recipeLock['version'],
178+
$lockVersion,
178179
$lockRef
179180
);
180181
} catch (TransportException $exception) {
@@ -183,16 +184,16 @@ private function displayPackageInformation(Recipe $recipe)
183184
}
184185

185186
$io->write('<info>name</info> : '.$recipe->getName());
186-
$io->write('<info>version</info> : '.($recipeLock['version'] ?? 'n/a'));
187+
$io->write('<info>version</info> : '.($lockVersion ?? 'n/a'));
187188
$io->write('<info>status</info> : '.$status);
188-
if (!$recipe->isAuto() && isset($recipeLock['version'])) {
189+
if (!$recipe->isAuto() && null !== $lockVersion) {
189190
$recipeUrl = sprintf(
190191
'https://%s/tree/%s/%s/%s',
191192
$lockRepo,
192193
// if something fails, default to the branch as the closest "sha"
193194
$gitSha ?? $lockBranch,
194195
$recipe->getName(),
195-
$recipeLock['version']
196+
$lockVersion
196197
);
197198

198199
$io->write('<info>installed recipe</info> : '.$recipeUrl);
@@ -202,7 +203,7 @@ private function displayPackageInformation(Recipe $recipe)
202203
$io->write('<info>latest recipe</info> : '.$recipe->getURL());
203204
}
204205

205-
if ($lockRef !== $recipe->getRef() && isset($recipeLock['version'])) {
206+
if ($lockRef !== $recipe->getRef() && null !== $lockVersion) {
206207
$historyUrl = sprintf(
207208
'https://%s/commits/%s/%s',
208209
$lockRepo,

src/Recipe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ public function isAuto(): bool
113113

114114
public function getVersion(): string
115115
{
116-
return $this->lock['version'];
116+
return $this->lock['recipe']['version'] ?? $this->lock['version'];
117117
}
118118
}

0 commit comments

Comments
 (0)