Bowler icon indicating copy to clipboard operation
Bowler copied to clipboard

Mirror logic that appends newline on patch application.

Open thatch opened this issue 4 years ago • 1 comments

The important parts are:

  • refactor_file adds a newline. it doesn't take it away, because
  • refactor_file calls processed_file which does an ast re-parse
  • apply_hunks has at least two bugs; one is the reported one about newlines, but it also appears to not obey cookies.

Ensuring that these 3 paths would always obey cookies and see contents that end with a newline seemed the simpler path. Includes a test that edits the (last, only, missing newline) line.

thatch avatar Oct 28 '20 03:10 thatch

Windows failures are new with this change; smoke-target goes from having a single LF to many CR followed by LF on disk, and I suspect git may be doing something here. We could paper over and have the patch use the same read_python_source function, but I'm a little uneasy about that.

Thoughts about just writing out a temp file with known contents, to avoid git mangling?

thatch avatar Oct 28 '20 03:10 thatch

Hi @thatch!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

facebook-github-bot avatar Dec 02 '22 16:12 facebook-github-bot