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

Add final rebase commit when landing if necessary to correct topology #90

Closed sven-of-cord closed 2 years ago

sven-of-cord commented 2 years ago

spr only allows landing a commit when merging the PR as-is will produce the same result on master as cherry-picking the local commit. This ensures that changes made to the local commit after last PR update are neither silently landed nor discarded. There is one edge case: if the local commit was previously based on another commit, that has now been landed, then Git may be able to merge the whole PR branch into master, understanding that there is a commit present in both master and the PR branch (including the base branch) since the latter branched off the former. In that case spr can go ahead with the landing. If you check the PR on GitHub afterwards, it will show not only changes in the landed commit, but also in the base of the commit. Those had been landed on master already, but they are also shown now as part of this PR. To get rid of this, we have to merge in the current master (which contains those other landed changes), so that those additional changes on base are no longer seen as coming from the PR branch (including the base branch). spr used to add a commit titled "[spr] landed version" when landing any PR. This PR brings back that "landed version" commit, however: only when it is necessary to have it to correct the topology. Also, very importantly, it never introduces changes by the author into the PR. If there are last-minute changes, spr still refuses to land (you have to do spr diff first).

Thanks to @nickfil22 for reporting this issue.

Test Plan:

Another test is to do an spr diff on the second commit just before landing. This will show that the commit has been rebased and therefore it updates the PR. With or without the changes in this PR: landing the second PR does not add a final rebase commit to the PR branch, and the contents of the PR after merging are displayed correctly.