-
Notifications
You must be signed in to change notification settings - Fork 80
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
base: master
Are you sure you want to change the base?
Optionally translate Git hosts to web hosts #134
Conversation
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".
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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
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".