Skydio / revup

Effortlessly create and manage pull requests without changing branches. Powers a stacked diffs workflow with python and git "plumbing" commands.
https://github.com/Skydio/revup
MIT License
310 stars 59 forks source link

Re-use topic names after a branch has been deleted #128

Open charlie-horn opened 11 months ago

charlie-horn commented 11 months ago

Is your feature request related to a problem? Please describe. When setting a topic name that has been used previously, but has since merged and the source branch has been deleted, the following error is thrown

user@machine:~/repo (main)$ revup upload
W: Couldn't find an existing label named main                                                                                                                                           
fatal: bad object b16af740cd878d0fc6a72cfdf955380390876085
Traceback (most recent call last):
  File "/home/user/.local/bin/revup", line 8, in <module>
    sys.exit(_main())
  File "/home/user/.local/lib/python3.8/site-packages/revup/__main__.py", line 18, in _main
    sys.exit(asyncio.run(main()))
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/user/.local/lib/python3.8/site-packages/revup/revup.py", line 393, in main
    return await upload.main(
  File "/home/user/.local/lib/python3.8/site-packages/revup/upload.py", line 53, in main
    await topics.mark_rebases(not args.rebase)
  File "/home/user/.local/lib/python3.8/site-packages/revup/topic_stack.py", line 705, in mark_rebases
    await self.git_ctx.rev_list(
  File "/home/user/.local/lib/python3.8/site-packages/revup/git.py", line 343, in rev_list
    return await self.git_stdout(*rev_list_args)
  File "/home/user/.local/lib/python3.8/site-packages/revup/git.py", line 289, in git_stdout
    return (await self.git(*args, **kwargs))[1]
  File "/home/user/.local/lib/python3.8/site-packages/revup/git.py", line 283, in git
    return _maybe_rstrip(await self.sh.sh(*((self.git_path,) + args), **kwargs))
  File "/home/user/.local/lib/python3.8/site-packages/revup/shell.py", line 216, in sh
    ret = self.handle_sh_results(ret, out, err, stdout, raiseonerror, *args)
  File "/home/user/.local/lib/python3.8/site-packages/revup/shell.py", line 279, in handle_sh_results
    raise RuntimeError("{} failed with exit code {}".format(" ".join(args), returncode))
RuntimeError: /usr/bin/git rev-list --reverse b16af740cd878d0fc6a72cfdf955380390876085 --first-parent --header --not 2f8e52470e2c5354d06e93181118e5ddf0ae7d49 failed with exit code 128

Describe the solution you'd like Unless it is already the topic of an active branch, I'd like to be able to re-use a topic name.

If that isn't possible, catching this error and displaying a message about topic name conflicts would be helpful for the user.

Describe alternatives you've considered The workaround for this would be to always set unique topic names per uploader.

jerry-skydio commented 6 months ago

we do currently support re-using topic names but you seem to have hit a corner case where it's broken

normally we look through pr infos in fetch_git_refs() and issue a fetch command for any oids that don't exist locally. i'm not sure why this didn't happen for you, can you run revup -v upload and paste that output for more info?

jerry-skydio commented 6 months ago

for example I re-used a topic name here and did a full git gc --prune=now https://github.com/Skydio/revup/pull/162. perhaps the commit id is being deleted from the github server as well although I would expect fetch to fail first in that case