ejoffe / spr

Stacked Pull Requests on GitHub
MIT License
796 stars 68 forks source link

Bug? PRs in wrong order on CLI #224

Closed yogurtearl closed 2 years ago

yogurtearl commented 2 years ago

Not sure if I am mis-understanding how spr works or if this is a bug. :)

The CLI is showing the stack is different order compared to the order shown in the PR description...

PR-11325 should be at the bottom and PR-11323 on the top...

Is spr getting confused because the newer PR (higher PR number) is on the bottom of the stack?

When I try to spr merge, it tries to merge in the wrong order.

PR-11325 is the parent commit of PR-11323

image image image

ejoffe commented 2 years ago

What you are describing sounds like a bug, although this logic has been very solid for a while, so it's a bit surprising.

When everything works correctly, both the cli and the added pr comment should show a stack growing upwards, meaning the oldest pr and first to merge should be at the bottom.

Did you do anything special to your commits to get into this state? How does the output of git log --oneline -n 2 compare with this? based on your description the commit corresponding to 11323 should be at the top?

yogurtearl commented 2 years ago

git log --oneline -n 3 shows essentially this:

abcd44: Commit for PR-11323
fedbcc:  Commit for PR-11325
d45fee: origin/main

reverse order of git spr s ... 🤔

at some point along the lines, after git amend, git spr u closed some PRs and reopened new ones for the same commit. So the older commit (fedbcc) got a newer PR number.

is the commit-id:fedbcc in the description how it tracks PRs across git amend changes? Maybe that got disturbed when I git amended?

is it getting confused by the PR numbers being in reverse order?

ejoffe commented 2 years ago

yes, commit-id is what spr uses to track and correlate between prs and commits. spr doesn't care about pr numbers, it uses the order of commits from the git log command to order the prs. if for some reason the commit-id is changed for a particular commit, after git spr update is called, the corresponding pr will be closed and a new one opened. git amend, as far as I know, should not be changing the commit-id in the commit description. It does feel like a weird combination of amend and spr update that's causing this issue.

ejoffe commented 2 years ago

Closing as a one off. Feel free to reopen if it occurs again.