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

🚀 Support custom hyperlink hash formats #613

Closed
HarrisonMc555 opened this issue May 25, 2021 · 7 comments · Fixed by #614
Closed

🚀 Support custom hyperlink hash formats #613

HarrisonMc555 opened this issue May 25, 2021 · 7 comments · Fixed by #614

Comments

@HarrisonMc555
Copy link

First of all, thanks for the great tool!

I think it's super cool that delta supports terminal hyperlinks. There's a lot of great support and documentation for file links, including a --hyperlinks-file-link-format flag that lets you customize how the file links are created.

There is also support for creating links for Git hashes. However, it appears that this is hard-coded to support GitHub repositories and nothing else.

Would you be open to adding a --hyperlinks-hash-link-format (or something like that)? I imagine it would be similar and simply have a {hash} placeholder.

If we wanted to go further, we could support the {hash} placeholder in the file link, which would allow users to open file links in their browser (or something) if they wanted. Just a thought 😃

@dandavison
Copy link
Owner

Hi @HarrisonMc555, thanks! Currently what delta does is look in the git repo config for remote.origin.url and parse that. And as you say, I only implemented parsing of Github URLs in my first pass and haven't yet gone back to add more. What do you think -- we could add parsing of URLs from other common git hosting sites pretty easily, and then it would be automatic, without the user having to construct a hash-link-format argument. Of course, the hash-link-format is ultimately more flexible, and we can do both. Ref #257 (comment)

@dandavison
Copy link
Owner

Looking into it more, I see that if the remote.origin.url is something like [email protected]:utilities/konsole.git then there doesn't seem much way for delta to know that that is a custom GitLab site (which I believe is the case) and hence that a commit should be formatted like https://invent.kde.org/utilities/konsole/-/commit/f8e06d55a2d2a7e322cc980052aa86d67d3aae17, so it does seem like we need the general hash-link-format argument, and perhaps also some auto-parsing of well-known formats.

@HarrisonMc555
Copy link
Author

@dandavison I agree with your conclusions. Parsing common formats (GitHub, GitLab, Bitbucket?) still seems like a nice default, but providing a hash-link-format would be necessary for any custom site. For example, my work uses a self-hosted Bitbucket server, which you wouldn't know just from the URL.

If you're open to it I'm willing to look into creating a pull request! I'm more than willing to take any pointers for getting started, though 😃

@dandavison
Copy link
Owner

dandavison commented May 26, 2021

If you're open to it I'm willing to look into creating a pull request!

Ah, I should have held off :) I actually already made the change (#614) but if you are interested in helping with some code contributions for delta that would be fantastic and I can always suggest tickets of different levels of effort (feel free to chat here or you can email me at [email protected]). Also understand if it was more this particular feature that was providing sufficient motivation :)

dandavison added a commit that referenced this issue May 26, 2021
dandavison added a commit that referenced this issue May 26, 2021
* Refactor: hyperlinks utility

* Add hyperlinks-commit-link-format option

Fixes #613
@dandavison
Copy link
Owner

OK, this has been added, thanks for the suggestion and sorry for stealing your PR! So for example, on master, I am able to do

git -c delta.hyperlinks-commit-link-format='https://invent.kde.org/utilities/konsole/-/commit/{commit}' log

and the commit is formatted as a hyperlink to https://invent.kde.org/utilities/konsole/-/commit/1cda384ec34e70ce052f8d177a8afcb665964663.

@HarrisonMc555
Copy link
Author

No worries! That was a quick turnaround 😃 thanks for the new feature!

@dandavison
Copy link
Owner

hyperlinks-commit-link-format is released now (delta 0.8.0)

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