Change line-endings to LF

Created on 17 August 2023, over 1 year ago
Updated 17 May 2024, 7 months ago

Problem/Motivation

We have a patch to support a scenario that might need a different issue -- we've extracted the domain name for the remote handler endpoint to a setting we can easily set to a different domain for different environments.

For now, we have this in a patch that we automatically apply when upgrading this module. That is, until the 3.x series, which changes the line endings to CRLF.

This entirely breaks the ability of the patch to be automatically applied by cweagans/composer-patches, the standard way to have Composer apply patches to Drupal code.

Steps to reproduce

1. Install webform_remote_handlers using Composer (composer require drupal/webform_remote_handlers)
2. Install cweagans/composer-patches (composer require cweagans/composer-patches).
3. Create a patch -- modify a handler, use `git diff --relative . > ../../../mypatch.patch` to export the change to a patch file
4. Add a block to the extras.patches section of the composer.json to apply the patch:

        "patches": {                                                                                                                                            
            "drupal/webform_remote_handlers": {                                                    
                "My patch": "mypatch.patch"
            }                                                                   
        },      

5. composer install.

This normally applies the patch to the module, but since 3.0, it errors out with:

Could not apply patch! Skipping. The error was: Cannot apply patch patches/webform_remote_handlers-endpoint-settings.patch

... if you try to apply the patch manually, using "patch -p1 < ../../../mypatch.patch" you get this:

patching file src/Plugin/WebformHandler/RestWebformHandler.php
Hunk #1 FAILED at 292 (different line endings).
Hunk #2 FAILED at 306 (different line endings).
2 out of 2 hunks FAILED -- saving rejects to file src/Plugin/WebformHandler/RestWebformHandler.php.rej

I can workaround this by opening the file in an editor, converting the line endings to LF, and then manually apply the patch. However, if there's anything that triggers it to reinstall, composer pulls down a fresh copy of the files with the bad file endings, and the patch gets reverted.

Proposed resolution

Update all committed files to use Unix line endings (LF) and not Windows (CRLF).

Remaining tasks

Resave all files and commit.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States freelock Seattle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024