spacedentist / spr

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

Fix occasional errors when pushing base branch to GitHub #69

Closed sven-of-cord closed 2 years ago

sven-of-cord commented 2 years ago

On two occasions, I have seen that spr diff failed with an error because it could not push the base branch to GitHub. The push failed because the new base branch commit was not constructed as a descendant of the current one. I debugged this: turns out that the GitHub API returned an base oid that did not refer to the current tip of the base branch. I assumed GitHub would always provide us with an up-to-date OID. I checked by using curl and making an API request manually, and I did this long after the last update of the base branch. So it seems that GitHub persisted a base OID for the pull request, and it sometimes is not the tip of the base branch. We can fix this by no longer using the OIDs provided by GitHub. This commit makes it so that we fetch the current state of PR and base branch and then use the current tip of those branches to construct the new commits. Previously, we used the given OIDs as parents of new commits.

Test Plan: cargo check && cargo test && cargo clippy && cargo build Use the new build of spr to submit and land this pull request. And then we will see if we get rid of the occasional failed push.