Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue where github.preserve-pull-request-description=true was adding \n to commit message. #880

Closed
wants to merge 1 commit into from

Conversation

bolinfest
Copy link
Contributor

Fix an issue where github.preserve-pull-request-description=true was adding \n to commit message.

Summary:
While #863 fixed some important
issues with respect to recognizing \r\n, it also introduced a new
issue where running sl pr s with github.preserve-pull-request-description=true
would inadvertently add an extra \n before the horizontal rule
delimiting the Sapling stack information.

This fixes create_pull_request_title_and_body() to preserve whatever
whitespace was originally present before the horizontal rule,
only adding a new \n to the end of the commit message if it did not
already have one.

Test Plan:

./tests/run-tests.py ./tests/test-doctest.py

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@sggutier
Copy link
Contributor

@bolinfest , seems like this breaks a couple of tests:

--- test-ext-github-pr-submit-overlap.t
+++ test-ext-github-pr-submit-overlap.t.err
@@ -26,5 +26,12 @@
   pushing 2 to [https://github.com/facebook/test_github_repo.git](https://l.facebook.com/l.php?u=https%3A%2F%2Fgithub.com%2Ffacebook%2Ftest_github_repo.git&h=AT1PWUuoEZmog7QbcQi0lQaaRWUt67iMUn2r3xY0ZDQtI7ROO4wXoZdES5COCoTR2PHg5hQHG8T_4ToaiSujNnetS8eABGo36t9JZuLsTVRYDezOnOB4kHW8mxscMJn3jHc1DPJo9rv2RctLVYc1IdgMPB0)
   created new pull request: [https://github.com/facebook/test_github_repo/pull/42](https://l.facebook.com/l.php?u=https%3A%2F%2Fgithub.com%2Ffacebook%2Ftest_github_repo%2Fpull%2F42&h=AT1PWUuoEZmog7QbcQi0lQaaRWUt67iMUn2r3xY0ZDQtI7ROO4wXoZdES5COCoTR2PHg5hQHG8T_4ToaiSujNnetS8eABGo36t9JZuLsTVRYDezOnOB4kHW8mxscMJn3jHc1DPJo9rv2RctLVYc1IdgMPB0)
   created new pull request: [https://github.com/facebook/test_github_repo/pull/43](https://l.facebook.com/l.php?u=https%3A%2F%2Fgithub.com%2Ffacebook%2Ftest_github_repo%2Fpull%2F43&h=AT1PWUuoEZmog7QbcQi0lQaaRWUt67iMUn2r3xY0ZDQtI7ROO4wXoZdES5COCoTR2PHg5hQHG8T_4ToaiSujNnetS8eABGo36t9JZuLsTVRYDezOnOB4kHW8mxscMJn3jHc1DPJo9rv2RctLVYc1IdgMPB0)
-  updated body for [https://github.com/facebook/test_github_repo/pull/43](https://l.facebook.com/l.php?u=https%3A%2F%2Fgithub.com%2Ffacebook%2Ftest_github_repo%2Fpull%2F43&h=AT1PWUuoEZmog7QbcQi0lQaaRWUt67iMUn2r3xY0ZDQtI7ROO4wXoZdES5COCoTR2PHg5hQHG8T_4ToaiSujNnetS8eABGo36t9JZuLsTVRYDezOnOB4kHW8mxscMJn3jHc1DPJo9rv2RctLVYc1IdgMPB0)
-  updated body for [https://github.com/facebook/test_github_repo/pull/42](https://l.facebook.com/l.php?u=https%3A%2F%2Fgithub.com%2Ffacebook%2Ftest_github_repo%2Fpull%2F42&h=AT1PWUuoEZmog7QbcQi0lQaaRWUt67iMUn2r3xY0ZDQtI7ROO4wXoZdES5COCoTR2PHg5hQHG8T_4ToaiSujNnetS8eABGo36t9JZuLsTVRYDezOnOB4kHW8mxscMJn3jHc1DPJo9rv2RctLVYc1IdgMPB0)
+  abort: Mock key has changed:
+  | @@ -1,5 +1,4 @@
+  |  github.com|graphql|None|base=main,body=two
+  | -
+  |  ---
+  |  [//]: # (BEGIN SAPLING FOOTER)
+  |  Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack]([https://reviewstack.dev/facebook/test_github_repo/pull/43).](https://l.facebook.com/l.php?u=https%3A%2F%2Freviewstack.dev%2Ffacebook%2Ftest_github_repo%2Fpull%2F43).&h=AT1PWUuoEZmog7QbcQi0lQaaRWUt67iMUn2r3xY0ZDQtI7ROO4wXoZdES5COCoTR2PHg5hQHG8T_4ToaiSujNnetS8eABGo36t9JZuLsTVRYDezOnOB4kHW8mxscMJn3jHc1DPJo9rv2RctLVYc1IdgMPB0)
+  
+  [255]

also:

--- test-ext-github-pr-submit-single.t
+++ test-ext-github-pr-submit-single.t.err
@@ -26,5 +26,12 @@
   pushing 2 to [https://github.com/facebook/test_github_repo.git](https://l.facebook.com/l.php?u=https%3A%2F%2Fgithub.com%2Ffacebook%2Ftest_github_repo.git&h=AT2UlEwYLoW_NGSb5abn8UCREllKnAP6WCnxtVYRfeXR4b5TtoUK4H8jO7ZNs7NDoZqYYRBMqCX5MRWY_1ZfAvUZCJnV0W2tiDaHw79EMiKmm8lv9si2iW81hfKPJf58NiDBgwIdMFuJFzIRNtgyXogdTvo)
   created new pull request: [https://github.com/facebook/test_github_repo/pull/42](https://l.facebook.com/l.php?u=https%3A%2F%2Fgithub.com%2Ffacebook%2Ftest_github_repo%2Fpull%2F42&h=AT2UlEwYLoW_NGSb5abn8UCREllKnAP6WCnxtVYRfeXR4b5TtoUK4H8jO7ZNs7NDoZqYYRBMqCX5MRWY_1ZfAvUZCJnV0W2tiDaHw79EMiKmm8lv9si2iW81hfKPJf58NiDBgwIdMFuJFzIRNtgyXogdTvo)
   created new pull request: https://github.com/facebook/test_github_repo/pull/43
-  updated body for [https://github.com/facebook/test_github_repo/pull/43](https://l.facebook.com/l.php?u=https%3A%2F%2Fgithub.com%2Ffacebook%2Ftest_github_repo%2Fpull%2F43&h=AT2UlEwYLoW_NGSb5abn8UCREllKnAP6WCnxtVYRfeXR4b5TtoUK4H8jO7ZNs7NDoZqYYRBMqCX5MRWY_1ZfAvUZCJnV0W2tiDaHw79EMiKmm8lv9si2iW81hfKPJf58NiDBgwIdMFuJFzIRNtgyXogdTvo)
-  updated body for https://github.com/facebook/test_github_repo/pull/42
+  abort: Mock key has changed:
+  | @@ -1,5 +1,4 @@
+  |  github.com|graphql|None|base=main,body=two
+  | -
+  |  ---
+  |  [//]: # (BEGIN SAPLING FOOTER)
+  |  Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack]([https://reviewstack.dev/facebook/test_github_repo/pull/43).](https://l.facebook.com/l.php?u=https%3A%2F%2Freviewstack.dev%2Ffacebook%2Ftest_github_repo%2Fpull%2F43).&h=AT2UlEwYLoW_NGSb5abn8UCREllKnAP6WCnxtVYRfeXR4b5TtoUK4H8jO7ZNs7NDoZqYYRBMqCX5MRWY_1ZfAvUZCJnV0W2tiDaHw79EMiKmm8lv9si2iW81hfKPJf58NiDBgwIdMFuJFzIRNtgyXogdTvo)
+  
+  [255]

@sggutier sggutier self-requested a review April 22, 2024 21:14
Copy link
Contributor

@sggutier sggutier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@facebook-github-bot
Copy link
Contributor

@bolinfest has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bolinfest
Copy link
Contributor Author

@sggutier I updated the two tests that you mentioned. Unfortunately, when I run:

./tests/run-tests.py ./tests/test-ext-github*.t

I admit I see a number of failures, but the messages I'm seeing give me the impression that not all of these tests are written to work in OSS Sapling?

…adding \n to commit message.

Summary:
While facebook#863 fixed some important
issues with respect to recognizing `\r\n`, it also introduced a new
issue where running `sl pr s` with `github.preserve-pull-request-description=true`
would inadvertently add an extra `\n` before the horizontal rule
delimiting the Sapling stack information.

This fixes `create_pull_request_title_and_body()` to preserve whatever
whitespace was originally present before the horizontal rule,
only adding a new `\n` to the end of the commit message if it did not
already have one.

Test Plan:
```
./tests/run-tests.py ./tests/test-doctest.py
```
@facebook-github-bot
Copy link
Contributor

@bolinfest has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@sggutier
Copy link
Contributor

I admit I see a number of failures, but the messages I'm seeing give me the impression that not all of these tests are written to work in OSS Sapling?

@bolinfest yeah, we should really try to make our tests more external-friendly, especially if those tests are testing OSS featurues

Copy link
Contributor

@sggutier sggutier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it seems like tests are now passing, so I'll try to get this merged soon

@facebook-github-bot
Copy link
Contributor

@sggutier merged this pull request in 6bd0c24.

@adamh-oai
Copy link

@bolinfest I think this introduced an issue where the last line of a commit is rendered as a header since it now looks like a "second level header" here: https://daringfireball.net/projects/markdown/basics. What issue did the extra newline cause?

@bolinfest
Copy link
Contributor Author

I agree and I have hit this, as well.

Before, I believe it was adding an extra new line every time I ran sl pr submit so on a PR that I updated multiple times, I ended up with a ton of newlines.

Agree I should fix it so there is exactly one before the horizontal separator.

I think the problem mainly happens when the PR at the bottom of the stack goes from "lone" to "stacked" because it had no trailing newline before the stack is appended.

facebook-github-bot pushed a commit that referenced this pull request Oct 16, 2024
Summary:
# Motivation

And if there is one is one design mistake Rust ecosystem made, it is making [`group_by` weird](rust-itertools/itertools#374) and possible for users to, quote:

> I spent several hours debugging my code written using the group_by function.

Luckily for internal users, the build tooling responds accordingly and fails build for all usages of deprecated API. Thus, there is a need to adjust all of them manually.

# [Release notes](https://github.com/rust-itertools/itertools/blob/master/CHANGELOG.md#0130)

### Breaking
- Removed implementation of `DoubleEndedIterator` for `ConsTuples` (#853)
- Made `MultiProduct` fused and fixed on an empty iterator (#835, #834)
- Changed `iproduct!` to return tuples for maxi one iterator too (#870)
- Changed `PutBack::put_back` to return the old value (#880)
- Removed deprecated `repeat_call, Itertools::{foreach, step, map_results, fold_results}` (#878)
- Removed `TakeWhileInclusive::new` (#912)

NOTE: Quick search didn't tell me anything related to breaking changes above, CI will tell. And, of course, scream to me if it breaks your personal build.

Reviewed By: anps77

Differential Revision: D64306014

fbshipit-source-id: 881ac716e1dc23968d4a28000fdaccdbf9097ec2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants