sodapopcan / vim-twiggy

Git branch management for Vim
280 stars 15 forks source link

Create pull request from the selected branch #26

Open kristijanhusak opened 5 years ago

kristijanhusak commented 5 years ago

Hi,

would you be interested in a feature where you would be able to open a link in a browser to a new pull request from the selected branch?

Feature would consist of these steps:

  1. Detect the remote service (github, bitbucket, gitlab)
  2. Generate link to a new pull request
  3. Open it up in default browser

Same thing i did for lazygit here https://github.com/jesseduffield/lazygit/pull/305

sodapopcan commented 5 years ago

First off, thanks for asking!

This is nice functionality, but I'm teetering back and forth on whether or not it belongs in Twiggy. For starters, I could see people wanting "open PR" functionality who have no interest in installing Twiggy. Secondly, my capacity for open source isn't huge and this would be a whole new feature that, once merged, I wouldn't be keen on supporting all by myself. I only use github and am wary of bitbucket/gitlab specific code in Twiggy as I have no interest in learning anything about either of those right now. Maybe that is an unfounded fear, though (it's not like Twiggy is super popular or anything).

@AndrewRadev actually already has a plugin for this, but it only supports github and doesn't seem to have much traction: https://github.com/AndrewRadev/ginitpull.vim. Also, the interface isn't as nice as the one you are suggesting (and is not a fugitive extension).

If you wanted to write your own version, I would be happy to provide a mechanism for integrating with Twiggy, or at least plugging it in the README. I am very interested in promoting a solid set of fugitive-based plugins.

TL;DR, I need to think on it a bit! I've changed my mind a few times while writing this, but that's how I'm feeling right now.

What do you think?

kristijanhusak commented 5 years ago

I agree that it potentially doesn't belong here, and that's fine.

In that case, it would be helpful to have an exposed function from twiggy that retrieves all branch information from branch under the cursor. That way i could just use that to gather all information.

sodapopcan commented 5 years ago

I am definitely open to exposing such a function (and will probably do so as part of providing a way to do custom mappings, see sodapopcan/vim-twiggy/issues/21), but if you're going to write your own plugin, I strongly suggest not having Twiggy as required a dependency! Definitely make it work on its own through a command, though maybe that is your plan anyway :)

I should also point out that my comments about Ginitpull's API were misguided—it totally makes sense that it's the way it is! If you had a similar API, I'd be happy to call-out in the Twiggy README on how to wire it up. Of course, auto-detecting and hooking into Twiggy is great too!

Now that there are two issues surrounding this, I'll expedite the custom mappings things.

sodapopcan commented 5 years ago

So I went ahead and exposed TwiggyBranchUnderCursor() because I won't have any time to work on stuff for the next few days. It's undocumented and "experimental" but it should get you going should you choose to go that route.

kristijanhusak commented 5 years ago

Looks good, thanks!

I'll close this up when i come up with a solution.

kristijanhusak commented 5 years ago

I created initial version.

https://github.com/kristijanhusak/vim-create-pr

Give it a test if you want and let me know how it looks.

sodapopcan commented 5 years ago

Looks nice! I have some feedback and will post to your repo this evening.