Skip to content

Commit 31326c1

Browse files
support optional .git at end of git remote (#621)
1 parent 6e0e772 commit 31326c1

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
;; always force unix line endings to make hashing consistent
22
* text eol=lf
33
*.png binary
4+
*.db binary

src/nextjournal/clerk/git.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#_(shell-out-str "zonk")
1313

1414
(defn ->github-project [remote-url]
15-
(second (re-find #"^git@github\.com:(.*)(\.git)?$" remote-url)))
15+
(second (re-find #"^git@github\.com:(.*?)(\.git)?$" remote-url)))
1616

1717
(defn ->https-git-url
1818
"Takes a git `remote-url` and tries to convert it into a https url for

test/nextjournal/clerk/git_test.clj

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(ns nextjournal.clerk.git-test
2+
(:require [clojure.test :refer [deftest is testing]]
3+
[nextjournal.clerk.git :as git]))
4+
5+
(deftest ->github-project
6+
(testing "works with .git suffix"
7+
(is (= "nextjournal/clerk"
8+
(git/->github-project "[email protected]:nextjournal/clerk.git"))))
9+
(testing "works without .git suffix"
10+
(is (= "nextjournal/clerk"
11+
(git/->github-project "[email protected]:nextjournal/clerk"))))
12+
(testing "works only for github"
13+
(is (nil? (git/->github-project "[email protected]:other/host.git")))))
14+
15+
(deftest ->https-git-url
16+
(testing "works for https"
17+
(is (= "https://github.com/nextjournal/clerk"
18+
(git/->https-git-url "https://github.com/nextjournal/clerk.git")))
19+
(is (= "https://gitlab.com/other/host"
20+
(git/->https-git-url "https://gitlab.com/other/host.git"))))
21+
(testing "rewrites github ssh to https"
22+
(is (= "https://github.com/nextjournal/clerk"
23+
(git/->https-git-url "[email protected]:nextjournal/clerk.git")))))
24+

0 commit comments

Comments
 (0)