Write SPR messages to a dedicated block inside commit messages #436
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #435 (and also #427).
What/why
As noted in the issue,
git spr update
can overwrite changes made to the PR title/description. To fix this, we can have a dedicated block that looks like this, which the code can search for.This way, any edits outside of this block are ignored. Since the block uses comments, it visually looks the same as before. And finally, if no block is present (e.g. on first commit or deleted by a user), it appends to the end.
Test plan
I added new test cases. In addition, I ran a manual test which you can see in https://github.com/rohan-mehta/spr-test-repo. The process was:
commit_1
,commit_2
,commit_3
, rungit spr update
, ensure that the spr stack description shows up.commit_1
(add stuff above the block) andcommit_2
(add stuff above and below the block), then re-rungit spr update
and ensure that nothing is overwritten.commit_2
, re-rungit spr update
and ensure that nothing is overwritten.commit_4
at the top of the stack, re-rungit spr update
and ensure that (a) a new PR is created (b) all previous PRs are updated to show the new commit (c) edits aren't overwritten