spacedentist / spr

Submit pull requests for individual, amendable, rebaseable commits to GitHub
https://getcord.github.io/spr/
MIT License
378 stars 33 forks source link

Fix `--update-message` option of `spr diff` when commit is unchanged #58

Closed sven-of-cord closed 2 years ago

sven-of-cord commented 2 years ago

@HenryDavies reported that the --update-message option of spr diff does not work. It looks like it only works when there were changes to the pull request (as in, the commit) to be submitted. When the user only changes the commit message, but makes no changes to the code, spr diff --update-message should still update the message on GitHub (but not submit a new commit to the pull request branch). This commit fixes this. The easiest way to fix this is to check whether --update-message was given when we do the early exit ("No update needed"), and then just update the message. This should be easier then getting rid of the early exit and then changing all the code below to not produce and push a commit, just so that the pull request update code that we already have (and that does update the message) is not skipped. I moved some of the code into a new method on PullRequestUpdate to reduce code duplication.

Test Plan:

sven-of-cord commented 2 years ago

Test plan completed. It worked nicely.