Patching .info.yml files

Migrated issue

Reported by: danepowell

It's difficult to patch project .info.yml files because of the way that Drupal packagist injects version info that isn't present in the source repositories for projects on git.drupal.org

If you need to patch a contributed module from Drupal.org, the typical workflow is to upload a patch to the project's issue queue (or find an existing patch), then update your composer.json to reference and apply the patch using cweagans/composer-patches. These patches are always generated against the project's codebase (on git.drupal.org).

The problem is that because Drupal.org packaging injects version information into .info.yml files that's not present in the source repo (git.drupal.org), any patches made against source repositories (of the type that would get uploaded to issue queues) do not apply cleanly. The workaround is fairly straightforward, you just have to generate patches against the packagist version of the package instead of the original version. But this is painful and definitely not intuitive.

At a minimum, I think it would be good to update documentation to reference this quirk in the packaging / patching system. I've already documented this at the bottom of this page.

Ideally, there'd be some way to eliminate this problem altogether, so that the packages on packagist are bit-for-bit identical to those on git.drupal.org. I'm not sure what such a solution would look like, I'm guessing it would require coordination between Drupal, composer, and composer patches. Maybe there could be a way to inject version information as a composer "post-install" hook or something.

Related issue: Issue #3066468

Edited by drupalbot