Closed bolinfest closed 7 months ago
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@quark-zju merged this pull request in facebook/sapling@cf8b16fbd2717b77b51de0d296486cd43376863c.
[github] update _strip_stack_information() to recognize \r\n
By default, Sapling programmatically writes the PR body on GitHub and will continue to overwrite it every time the user runs
sl pr submit
. In so doing, Sapling always uses\n
as the line terminator for the content it generates.However, if the user has
github.preserve-pull-request-description=true
set and edits the pull request body on GitHub, then the next time Sapling pulls down the pull request body to parse it, it will find that the original line terminators it wrote will have been changed to\r\n
.Previous to this commit,
_strip_stack_information()
always looked for_HORIZONTAL_RULE
and_SAPLING_FOOTER_MARKER
joined with\n
, which failed to match the newly written version containing\r\n
. This meant that users withgithub.preserve-pull-request-description=true
set would end up getting an extra copy of the stack information written to the PR body after runningsl pr submit
because the first instance was considered the source of the PR body that Sapling was not supposed to modify based ongithub.preserve-pull-request-description=true
.This commit changes
_strip_stack_information()
to match the pattern using a regex that recognizes both\n
and\r\n
as the line terminator.Added a doctest to
_strip_stack_information()
and verified the following passes locally: