Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use upstream ref if possible #42

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

markrian
Copy link

@markrian markrian commented Oct 8, 2020

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 #10.

Co-authored-by: souldzin [email protected]

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 ruanyl#10.

Co-authored-by: souldzin <[email protected]>
@markrian
Copy link
Author

markrian commented Oct 8, 2020

@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! 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant