sshaw / git-link

Emacs package to get the GitHub/Bitbucket/GitLab/... URL for a buffer location
394 stars 73 forks source link

Regression - incorrect directory passed to function in "git-link-remote-alist" #95

Open edkolev opened 2 years ago

edkolev commented 2 years ago

Hi, I updated the git-link package to the latest one and my custom function in "git-link-remote-alist" stopped working (produces incorrect URLs).

I've been using git-link for 3+ years without any issues with the config pasted below.

The issue is DIRNAME passed to my function is invalid. I've narrowed down the issue to git-link--parse-remote.

Here's how to reproduce it:

(git-link--parse-remote "gitolite@my.company.internal:dir")
;; returns ("my.company.internal" "/")
;; expected ("my.company.internal" "dir")

This is the git config:

$ git config --get remote.origin.url
gitolite@my.company.internal:dir/

Could you please review the parsing in git-link--parse-remote? I suspect it has changed. I haven't binary-searched for the breaking commit, but it should be committed the last 1-2 years. Sorry, I don't know what was the previous version which was working for me. EDIT: last working version is in the comment below.

Thanks for this package, it has been one of my daily tools!

Config ("XXX" obfuscates what I don't want to share):

(use-package git-link
  :ensure t
  :config
  (add-to-list 'git-link-remote-alist '("XXX" git-link-xxx))

  (defun git-link-xxx (hostname dirname filename branch commit start end)
    (format "XXX/%s/%s@%s/-/blob/%s"
            hostname
            dirname
            (or branch commit)
            (concat filename
                    (when start
                      (concat "#"
                              (if end
                                  (format "L%s-%s" start end)
                                (format "L%s" start))))))))
edkolev commented 2 years ago

Just did a quick check - v0.8.0 is the last working version, v0.8.1 doesn't work:

(git-link--parse-remote "gitolite@my.company.internal:dir")
;; v0.8.0 returns ("my.company.internal" "dir/")
;; v0.8.1 returns ("my.company.internal" "/")
sshaw commented 2 years ago

Thanks for the info @edkolev. Bad test coverage here unfortunately 🔴