-
Notifications
You must be signed in to change notification settings - Fork 74
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
Ability to resolve using OpenSSH client configuration file #116
Conversation
Hi, thanks for the PR! To make sure I understand, your git remote uses |
@@ -431,10 +436,16 @@ return (FILENAME . REVISION) otherwise nil." | |||
(when (string-match ":" host) | |||
(let ((parts (split-string host ":" t)) | |||
(case-fold-search t)) | |||
(string-match (concat (car parts) ":\\(" (cadr parts) "\\)/") url) | |||
(string-match (concat (regexp-quote (car parts)) ":\\(" (cadr parts) "\\)/") url) |
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.
👍
Yes. The remote for my repository looks like this:
|
git-link.el
Outdated
"Resolve HOSTNAME using ssh client." | ||
(let ((output (shell-command-to-string (format "ssh -G %s" hostname))) | ||
(host nil)) | ||
(dolist (line (string-split output "\n")) |
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.
string-split
, where does this come from? I do not have it in my Emacs. Using 27.2
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.
Also on Window will this be \n
or \r\n
?
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.
It comes from subr.el which comes with Emacs 29.1. I will see what I can do to support older versions.
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.
What about this?
(defun find-it (host)
(with-temp-buffer
(call-process "/usr/bin/ssh" nil (list (current-buffer) nil) nil "-G" host)
(beginning-of-buffer)
(when (search-forward-regexp "^hostname \\(.*\\)")
(match-string 1))))
Should take care of the Windows line terminator problem. If it was even a problem.
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.
Well (defun git-link--ssh-resolve-hostname ...)
😉
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.
Should also just be "ssh"
, right?
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.
@sshaw Sorry, this took more time to come back than what I expected. I have replaced string-split
with split-string
which is available from Emacs 20.1. In fact string-split
is a defalias
to it.
Also, I have been using this functionality for couple of months at work now and didn't face any issues.
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.
Hi, great thanks for the update!
Do we know \n
will work on Windows? It's okay if not.
Can you squash into a single commit?
Also added one question about cond
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.
Do we know \n will work on Windows? It's okay if not.
It won't work. I can make it portable if you want, but I wouldn't be able to test it on a Windows machine since I don't have one.
Can you squash into a single commit?
Done, thanks!
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.
Do we know \n will work on Windows? It's okay if not.
It won't work. I can make it portable if you want, but I wouldn't be able to test it on a Windows machine since I don't have one.
And I just uninstalled my Virtual Box Windows (7!) image. Should just be a matter of changing "\n"
to "\r?\n"
but we can do that latter.
Thanks for the work!
So I have this setup where I use a different github account and a different private key configured like this in my ~/.ssh/config Host github+myorg IdentitiesOnly yes HostName github.com IdentityFile ~/.ssh/myorg_id_rsa This PR provides the ability to support such configuration. I have disabled it by default since this is not a common setup most peoples have.
Release in v0.9.1 |
Thank you! |
So I have this setup where I use a different github account and a different private key configured like this in my ~/.ssh/config
This PR provides the ability to support such configuration. I have disabled it by default since this is not a common setup most peoples have.