ruanyl / vim-gh-line

vim plugin that open the link of current line on github
MIT License
408 stars 37 forks source link

Use upstream ref if possible #42

Open markrian opened 3 years ago

markrian commented 3 years ago

When the current branch tracks an upstream branch, generate a link to that upstream branch (or SHA) rather than using the local one, since it may not exist upstream.

In the case that the local branch has no upstream, prompt the user for the branch name to generate a link for.

Partly addresses https://github.com/ruanyl/vim-gh-line/issues/10.

Co-authored-by: souldzin souldzin@souldzin.com

markrian commented 3 years ago

@souldzin and I worked on this last week. It's preliminary, e.g., there are no additional tests for this, hence the draft status.

The main goal was to avoid generating a 404 link in the case that the current HEAD commit doesn't exist on the remote (which, for me, is the case the majority of the time).

Some other possible approaches that might be better:

  1. Expose this functionality via a different command, e.g., :GHPreferRemote
  2. Add a g:gh_prefer_remote variable, default disabled, to enable this behaviour
  3. Replace this via a g:gh_ref_command variable, which is a command/script which gets the ref to use to build the link. For example, this could be used to get the latest tag, or find the "nearest" commit that exists on the remote. I quite like this approach, since it makes the heuristic completely user-configurable!

I'd really appreciate any thoughts on how to carry this forward! 🙇