davidrjonas / composer-lock-diff

See what has changed after a composer update
MIT License
274 stars 18 forks source link

Diff URLs truncated #26

Closed xurizaemon closed 2 years ago

xurizaemon commented 4 years ago

Just testing this out (thanks!) and noticed that some of the URLs provided for compare are truncated. Eg:

| drupal/entity_reference_revisions     | 1.7.0        | 1.8.0        | https://git.drupalcode.org/project/entity_reference_revisions/compare/8.x-1.7...8.x-1.8  |
| drupal/fast_404                       | 1.0.0-alpha4 | 1.0.0-alpha5 | https://git.drupalcode.org/project/fast_404/compare/8.x-1.0.0-alph...8.x-1.0.0-alph      |
| drupal/page_manager                   | 4.0.0-beta4  | 4.0.0-beta5  | https://git.drupalcode.org/project/page_manager/compare/8.x-4.0.0-bet...8.x-4.0.0-bet    |
| drupal/views_data_export              | 1.0.0-beta4  | 1.0.0-rc1    | https://git.drupalcode.org/project/views_data_export/compare/8.x-1.0.0-bet...8.x-1.0.0-r |

(I've intentionally excerpted to show a single correct URL and some that are not working links.)

These output URLs do not provide comparison views correctly, while most do:

In worst case this might result in deceptive output (eg diff vs -beta1 links to -beta, or diff vs -beta11 links to -beta1).

tput cols returns 236; these are not shortened due to limitations of the console AFAICT. See screenshot below.

image

davidrjonas commented 4 years ago

Well that’s odd. It looks to do with the version string. See the missing “a4” at the end of “alpha4” for fast_404? I’m on mobile at the moment but lll take a look as soon as I can.

Thanks for reporting it!

On May 7, 2020, at 6:50 PM, Chris Burgess notifications@github.com wrote:

 Just testing this out (thanks!) and noticed that some of the URLs provided for compare are truncated. Eg:

| drupal/entity_reference_revisions | 1.7.0 | 1.8.0 | https://git.drupalcode.org/project/entity_reference_revisions/compare/8.x-1.7...8.x-1.8 | | drupal/fast_404 | 1.0.0-alpha4 | 1.0.0-alpha5 | https://git.drupalcode.org/project/fast_404/compare/8.x-1.0.0-alph...8.x-1.0.0-alph | | drupal/page_manager | 4.0.0-beta4 | 4.0.0-beta5 | https://git.drupalcode.org/project/page_manager/compare/8.x-4.0.0-bet...8.x-4.0.0-bet | | drupal/views_data_export | 1.0.0-beta4 | 1.0.0-rc1 | https://git.drupalcode.org/project/views_data_export/compare/8.x-1.0.0-bet...8.x-1.0.0-r | (I've intentionally excerpted to show a single correct URL and some that are not working links.)

tput cols returns 236; these are not shortened due to limitations of the console AFAICT. See screenshot below.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

xurizaemon commented 4 years ago

The cause isn't obvious to me either. It would be remiss to not share this E_NOTICE output, even though I don't think it's related.

PHP Notice:  Undefined property: stdClass::$source in /vagrant/.composer/vendor/davidrjonas/composer-lock-diff/composer-lock-diff on line 212
PHP Stack trace:
PHP   1. {main}() /vagrant/.composer/vendor/davidrjonas/composer-lock-diff/composer-lock-diff:0
PHP   2. diff() /vagrant/.composer/vendor/davidrjonas/composer-lock-diff/composer-lock-diff:9
PHP   3. makeCompareUrl() /vagrant/.composer/vendor/davidrjonas/composer-lock-diff/composer-lock-diff:65
PHP Notice:  Trying to get property 'url' of non-object in /vagrant/.composer/vendor/davidrjonas/composer-lock-diff/composer-lock-diff on line 212
PHP Stack trace:
PHP   1. {main}() /vagrant/.composer/vendor/davidrjonas/composer-lock-diff/composer-lock-diff:0
PHP   2. diff() /vagrant/.composer/vendor/davidrjonas/composer-lock-diff/composer-lock-diff:9
PHP   3. makeCompareUrl() /vagrant/.composer/vendor/davidrjonas/composer-lock-diff/composer-lock-diff:65

(that appears twice in the output, but not as many times as there are truncated URLs, therefore I doubt it's the cause ... but it is coming from makeCompareUrl so maybe I'm wrong!)

If I can't track the problem down I'll attach a sample composer.json & lock to demo :grin:

davidrjonas commented 4 years ago

The truncation is strange. The second line of your example is truncated at 14 characters and the next two are at 13. The only place in the code that manipulates the version received from the lock files is 75 and that truncates to 7 places for git hashes. Can you provide the source files?

Also, are you using a current version? Line 212 is

return call_user_func($func, @$pkg->source->url, $diff[$pkg->name][0], $diff[$pkg->name][1]);

The @ should suppress those notices.

davidrjonas commented 2 years ago

I think this is corrected with the changes to drupalcode handling in 1.6.0. Please reopen if it is not.