vim-rhubarb
vim-rhubarb copied to clipboard
Open PR associated with blame
If I blame a line I get the associated commit. Then I have to yank it and copy it into https://github.com/foo/bar/commit/abcd123 and click on the PR.
It would be nice if I could do this directly from the editor.
I also have a simiar workflow where I want to open the PR that merged a particular commit.
I used to use git when-merged but realising that GitHub has an api for finding the PR, I wrote a plugin to do that.
GitHub API docs for listing PRs associated with a commit (note that there can be more than 1) https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-pull-requests-associated-with-a-commit
I structured it in a similar way to how rhubarb interfaces with GitHub, with the idea that I could maybe move parts of the logic to rhubarb/fugitive-gitlab and other parts to fugitive. That would allow fugitive to control the commands/bindings and git, with the logic for obtaining the url delegated to rhubarb/fugitive-gitlab. I'm in two minds as to whether its worth it though.
Anyway, my plugin demonstrates how this could work for both GitHub/rhubarb and GitLab/fugitive-gitlab https://github.com/shumphrey/vimrc/blob/master/plugin/mergerequest.vim
If I blame a line I get the associated commit. Then I have to yank it and copy it into https://github.com/foo/bar/commit/abcd123
This is just :GBrowse with extra steps.
and click on the PR.
So this feature request boils down to saving you a click. That's not nothing; I do this operation a lot myself so I see the appeal. But I'm inclined to think it doesn't justify adding a whole top level command to Fugitive.
There is the potential for saving a few more clicks/commands if there's a command to bypass blame and go straight from current line to PR that introduced that line. But I don't disagree adding an entirely new set of commands for this seems like overkill.