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

🚀 Show Github commit hyperlinks even if remote URL does not contain git@ #667

Closed
spaarmann opened this issue Jul 25, 2021 · 5 comments · Fixed by #668
Closed

🚀 Show Github commit hyperlinks even if remote URL does not contain git@ #667

spaarmann opened this issue Jul 25, 2021 · 5 comments · Fixed by #668

Comments

@spaarmann
Copy link
Contributor

Hi! I was recently a bit confused why hyperlinks for commits were working in some of my local clones but not others.
After a bit of investigation I've figured out that it's caused by the remote URL being simply github.com:user/repo instead of git@github.com:user/repo, which is not matched by the current regex.

Now, this remote URL only works in the first place because of a custom SSH config containing something like this:

Host github.com
    HostName github.com
    User git
    IdentityFile <some key>

Considering that I fully understand if you'd prefer to not support such configs out-of-the-box. (You can also put anything into the Host portion there and have it still end up going to GitHub with configs like this and I imagine that parsing the SSH config or anything similar to make everything here work is definitely out of scope 😄 ).

Still, I figured specifically allowing omitting the git@ is a pretty small change so I might as well ask (and I suspect this is at least a somewhat common config; I don't remember where I stole it, but I definitely got the idea from someone else).

@spaarmann
Copy link
Contributor Author

(Fwiw, if you deem this to a feature you want included in the first place, I'd be happy to submit a PR adding it if that's useful :)

@dandavison
Copy link
Owner

Hi @spaarmann, we recently added this option:

        --hyperlinks-commit-link-format <hyperlinks-commit-link-format>
            Format string for commit hyperlinks (requires --hyperlinks). The placeholder "{commit}" will be replaced by
            the commit hash. For example: --hyperlinks-commit-link-format='https://mygitrepo/{commit}/'

Am I right in thinking that that can be used to solve this? (It takes precedence over the auto-recognizing of github URLs)

@spaarmann
Copy link
Contributor Author

That could be used to make hyperlinks work but unless I'm missing something, I believe that would have to be configured for every repository / clone separately, because the custom format would have to include the user/repo part. The main advantage of tweaking the Regex is that it would work for every repository automatically.

@dandavison
Copy link
Owner

Yes, you're right. Ok, sure, it would be great if you're able to improve this regex!

@spaarmann
Copy link
Contributor Author

Great! I'm about to go to bed, but I'll look at sending a PR tomorrow.

spaarmann added a commit to spaarmann/delta that referenced this issue Jul 26, 2021
…erlinks

Closes dandavison#667.

SSH remote URLs are usually formatted as `git@github.com:user/repo` but
certain setups can allow using just `github.com:user/repo`, see issue dandavison#667
for an example.
This modifies the regex used to detect a GitHub remote for hyperlink
generation to also allow the latter form.
dandavison pushed a commit that referenced this issue Jul 26, 2021
…erlinks (#668)

Closes #667.

SSH remote URLs are usually formatted as `git@github.com:user/repo` but
certain setups can allow using just `github.com:user/repo`, see issue #667
for an example.
This modifies the regex used to detect a GitHub remote for hyperlink
generation to also allow the latter form.
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 a pull request may close this issue.

2 participants