Skip to content

Commit

Permalink
Support both dist and source to determine if dev package was updated
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm committed Feb 8, 2021
1 parent 0958356 commit 4d267ed
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/LockDataComparer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,25 @@ public function getUpdateList()
} else {
if ($old_package->version === $package->version) {
// Well, unless they are actually on for example dev-master. Then we compare the dist hashes.
if (empty($old_package->dist->reference) || empty($package->dist->reference)) {
continue;
$is_the_same = true;
// For some packages, the dist part can be empty, but the version differ in the source hash. So
// we compare them both.
$useful_dist_property = 'dist';
foreach (['dist', 'source'] as $key) {
if (empty($old_package->{$key}->reference) || empty($package->{$key}->reference)) {
continue;
}
if ($old_package->{$key}->reference === $package->{$key}->reference) {
continue;
}
$is_the_same = false;
$useful_dist_property = $key;
}
if ($old_package->dist->reference === $package->dist->reference) {
if ($is_the_same) {
continue;
}
$old_package->version = sprintf('%s#%s', $old_package->version, $old_package->dist->reference);
$package->version = sprintf('%s#%s', $package->version, $package->dist->reference);
$old_package->version = sprintf('%s#%s', $old_package->version, $old_package->{$useful_dist_property}->reference);
$package->version = sprintf('%s#%s', $package->version, $package->{$useful_dist_property}->reference);
}
$list[] = new UpdateListItem($package->name, $package->version, $old_package->version);
}
Expand Down

0 comments on commit 4d267ed

Please sign in to comment.