backdrop-contrib / coder_upgrade

Helps automate some/most of the work required to upgrade a module from Drupal to Backdrop 1.x
GNU General Public License v2.0
4 stars 7 forks source link

Windows line endings cause a problem #70

Open docwilmot opened 2 years ago

docwilmot commented 2 years ago

If you clone a repo from Drupal it comes with Windows line endings. But when you run through CU its parser/writer routines use Linux line endings, so your file ends up with a mix. See this file here: Capture Notice all the line endings are LF until the end of the Implements hook_field_extra_fields(). comment, when it switches to CR. This happens for all the Implements hook_wwwww(). lines. It may be this is the only write routine thats messed up since I haven't seen any other problems like this. If you convert the file to Linux line endings first, this doesnt happen.

klonos commented 1 year ago

@docwilmot I cannot reproduce this on Mac OS 🤔 ...are you running things on Windows?

I just tried to convert https://git.drupalcode.org/project/menu_trail_by_path/-/tree/7.x-3.x, and I got no weird (). lines:

 /**
- * Implements hook_menu()
+ * Implements hook_menu().
  */
 function menu_trail_by_path_menu() {

Can you please let me know of a D7 module that you were able to successfully reproduce this issue with?

klonos commented 1 year ago

...in the meantime, I have taken a look at the regex used in coder_upgrade_upgrade_hook_alter():

'@\*\s+[iI]mplement.*?(hook_.*?)(\(\)|)(\.|)$@m'`

I have the following remarks for moment (untested, but pretty sure about these):

Anyway, I will need to be able to reproduce this issue first before I can try things and confirm 100% all of the above. I will also need to have a better understanding of the sequence of things coder_upgrade is trying to do, because as you said @docwilmot:

If you convert the file to Linux line endings first, this doesnt happen.

That ^^ may be the answer/solution.

docwilmot commented 1 year ago

This was of course all "Greek" to me. 😄