adt/objects: normalize CRLF in Class.Include.text#176
Conversation
The base ADTObject.text already replaces \r\n with \n before returning the source. Class.Include.text (used for class testclasses, locals_def and locals_imp) was missing the same normalization, returning the raw \r\n string from ADT. On Windows this surfaces when checkout writes the file in text mode (open(..., 'w')): the existing \r\n is treated as \n and translated again, ending up as \r\r\n on disk and rendering as a blank line under every line in editors. Linux text-mode IO does no translation, which is why the bug had not been noticed. Mirror the long-standing pattern from ADTObject.text (sap/adt/objects.py:723) so both code paths return source with LF-only line endings.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesCRLF Normalization in Class.Include.text
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Well done! Can you please ask your agent to: Add the test case to the file
and the assert should do full source code equality |
|
I pushed af62bfd |
Summary
Class.Include.text(used when checking out a class'stestclasses,locals_defandlocals_impincludes) returned the raw response from ADT, which uses\r\nline endings. The baseADTObject.text(sap/adt/objects.py:723) has long normalized\r\n->\nbefore returning; this override was missing the same call.Symptom (Windows)
sap.cli.checkoutopens the target file in text mode (open(filename, 'w', encoding='utf8')). On Windows, text-mode write translates each\n->\r\n. When the source already contains\r\n, the result on disk is\r\r\n-- every line renders with a blank line under it in VS Code and other editors.Linux text-mode IO performs no translation, which is why the issue was invisible upstream.
Fix
One-line change: append
.replace('\r\n', '\n')to the override, mirroring the pattern already used byADTObject.text. Same call, same semantics -- safe on Linux (no-op when there are no\r\nsequences).Files
sap/adt/objects.py--Class.Include.text