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

Optionally translate Git hosts to web hosts #134

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

Conversation

sebastianpoeplau
Copy link

Add an option to translate Git hosts to web hosts in order to support setups where the two are different. For example, Git access could be via "ssh.gitlab.company.com" and the web interface at "gitlab.company.com".

Add an option to translate Git hosts to web hosts in order to support
setups where the two are different. For example, Git access could be via
"ssh.gitlab.company.com" and the web interface at "gitlab.company.com".
@sshaw
Copy link
Owner

sshaw commented Jan 26, 2025

Hi, thanks so much for the PR. I'm surprised this issue has not come up befor. #32 is the closest I could find.

filename (git-link--relative-filename)
branch (git-link--branch)
commit (git-link--commit)
handler (git-link--handler git-link-remote-alist (car remote-info)))
handler (git-link--handler git-link-remote-alist git-host)
web-host (or (assoc-default git-host git-link-web-host-alist) git-host))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use assoc since we're using or to provide a default; or, provide the default to assoc-default. I think the rest of code uses the or pattern so maybe that is a better choice?

Copy link
Author

@sebastianpoeplau sebastianpoeplau Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with assoc is that it returns the pair (key . value), so that we'd have (cdr (assoc ...)). No problem if that's what you prefer, but the extra cdr is why I didn't use it. As for assoc-default, unfortunately it respects the default value only for keys that are in the list but not associated with any value. For example:

(assoc-default 'apple  '((apple . red) pear) nil 'unknown) ;; -> red
(assoc-default 'pear   '((apple . red) pear) nil 'unknown) ;; -> unknown
(assoc-default 'orange '((apple . red) pear) nil 'unknown) ;; -> nil, not unknown as we'd expect...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes I see. Thanks for clarifying.

Looks good then, just one question: the other host-related alists do a regex match on the host, should we do that here for consistency?

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.

2 participants