Skip to content

Commit

Permalink
Strip suffix on remote path only if it ends in .git
Browse files Browse the repository at this point in the history
  • Loading branch information
weshmashian committed Oct 25, 2018
1 parent efd14ab commit d7fa8f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions git-link-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
(should (equal '("orgmode.org" "org-mode")
(git-link--parse-remote "https://orgmode.org/org-mode.git")))

(should (equal '("gitlab.com" "weshmashian/emacs.d")
(git-link--parse-remote "https://gitlab.com/weshmashian/emacs.d")))

(should (equal '("foo-bar.github.com" "sshaw/foo/x")
(git-link--parse-remote "https://user:password@foo-bar.github.com/sshaw/foo/x.git")))
6 changes: 5 additions & 1 deletion git-link.el
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ return (FILENAME . REVISION) otherwise nil."
(when host
(when (and (not (string= "/" path))
(not (string= "" path)))
(setq path (substring (file-name-sans-extension path) 1)))
(setq path (substring
(if (string-suffix-p ".git" path)
(file-name-sans-extension path)
path)
1)))

;; Fix-up scp style URLs
(when (string-match ":" host)
Expand Down

0 comments on commit d7fa8f6

Please sign in to comment.