@@ -11,34 +11,65 @@ spec :: Spec Unit
1111spec = do
1212 Spec .describe " Git" do
1313 Spec .describe " parseRemote" do
14+ Spec .describe " successfully parses" do
15+ let
16+ mkTest input expectedUrl = Spec .it input $ parseRemote input `shouldEqual` Just { name: " origin" , url: expectedUrl, owner: " foo" , repo: " bar" }
1417
15- Spec .it " parses a remote with a git protocol" do
16- parseRemote
" origin\t [email protected] :foo/bar.git (fetch)" 17- `shouldEqual` Just { name:
" origin" , url:
" [email protected] :foo/bar.git" , owner:
" foo" , repo:
" bar" }
18- parseRemote
" origin [email protected] :foo/bar.git (fetch)" 19- `shouldEqual` Just { name:
" origin" , url:
" [email protected] :foo/bar.git" , owner:
" foo" , repo:
" bar" }
18+ Spec .describe " remote with a git protocol" do
19+ mkTest
" origin\t [email protected] :foo/bar.git (fetch)" " [email protected] :foo/bar.git" 20+ mkTest
" origin [email protected] :foo/bar.git (fetch)" " [email protected] :foo/bar.git" 21+ -- spago should be tolerant to missing .git
22+ mkTest
" origin\t [email protected] :foo/bar (fetch)" " [email protected] :foo/bar" 23+ mkTest
" origin [email protected] :foo/bar (fetch)" " [email protected] :foo/bar" 2024
21- Spec .it " parses a remote with an https protocol" do
22- parseRemote " origin\t https://github.com/foo/bar.git (push)"
23- `shouldEqual` Just { name: " origin" , url: " https://github.com/foo/bar.git" , owner: " foo" , repo: " bar" }
24- parseRemote " origin https://github.com/foo/bar.git (push)"
25- `shouldEqual` Just { name: " origin" , url: " https://github.com/foo/bar.git" , owner: " foo" , repo: " bar" }
25+ Spec .describe " remote with an https protocol" do
26+ mkTest " origin\t https://github.com/foo/bar.git (push)" " https://github.com/foo/bar.git"
27+ mkTest " origin https://github.com/foo/bar.git (push)" " https://github.com/foo/bar.git"
28+ -- spago should be tolerant to missing .git
29+ mkTest " origin\t https://github.com/foo/bar (push)" " https://github.com/foo/bar"
30+ mkTest " origin https://github.com/foo/bar (push)" " https://github.com/foo/bar"
2631
27- Spec .it " parses a remote with an ssh protocol" do
28- parseRemote
" origin\t ssh://[email protected] /foo/bar.git (push)" 29- `shouldEqual` Just { name:
" origin" , url:
" ssh://[email protected] /foo/bar.git" , owner:
" foo" , repo:
" bar" }
30- parseRemote
" origin ssh://[email protected] /foo/bar.git (push)" 31- `shouldEqual` Just { name:
" origin" , url:
" ssh://[email protected] /foo/bar.git" , owner:
" foo" , repo:
" bar" }
32+ Spec .describe " remote with an https protocol" do
33+ mkTest " origin\t http://github.com/foo/bar.git (push)" " http://github.com/foo/bar.git"
34+ mkTest " origin http://github.com/foo/bar.git (push)" " http://github.com/foo/bar.git"
35+ -- spago should be tolerant to missing .git
36+ mkTest " origin\t http://github.com/foo/bar (push)" " http://github.com/foo/bar"
37+ mkTest " origin http://github.com/foo/bar (push)" " http://github.com/foo/bar"
3238
33- Spec .it " rejects malformed remotes" do
34- parseRemote
" origin\t [email protected] :foo/bar.git" `shouldEqual` Nothing 35- parseRemote
" origin [email protected] :foo/bar.git" `shouldEqual` Nothing 39+ Spec .describe " remote with an ssh protocol" do
40+ mkTest
" origin\t ssh://[email protected] /foo/bar.git (push)" " ssh://[email protected] /foo/bar.git" 41+ mkTest
" origin ssh://[email protected] /foo/bar.git (push)" " ssh://[email protected] /foo/bar.git" 42+ -- spago should be tolerant to missing .git
43+ mkTest
" origin\t ssh://[email protected] /foo/bar (push)" " ssh://[email protected] /foo/bar" 44+ mkTest
" origin ssh://[email protected] /foo/bar (push)" " ssh://[email protected] /foo/bar" 3645
37- parseRemote " origin \t [email protected] :foo/bar (push)" `shouldEqual` Nothing 38- parseRemote " origin [email protected] :foo/bar (push) " `shouldEqual` Nothing 46+ Spec .describe " rejects " do
47+ let mkTest input = Spec .it input $ parseRemote input `shouldEqual` Nothing
3948
40- parseRemote
" origin\t [email protected] :foo.git (push)" `shouldEqual` Nothing 41- parseRemote
" origin [email protected] :foo.git (push)" `shouldEqual` Nothing 49+ Spec .describe " rejects malformed remotes" do
50+ Spec .describe " missing trailing (push) or (fetch) field" do
51+ -- yes, not possible even if edit .git/config
52+ mkTest
" origin\t [email protected] :foo/bar.git" 53+ mkTest
" origin [email protected] :foo/bar.git" 4254
43- parseRemote " origin\t https://foo.com/bar.git (push)" `shouldEqual` Nothing
44- parseRemote " origin https://foo.com/bar.git (push)" `shouldEqual` Nothing
55+ Spec .describe " missing repo name (with or without .git given)" do
56+ -- git
57+ mkTest
" origin\t [email protected] :foo.git (push)" 58+ mkTest
" origin [email protected] :foo.git (push)" 59+ mkTest
" origin\t [email protected] :foo (push)" 60+ mkTest
" origin [email protected] :foo (push)" 61+ -- https
62+ mkTest " origin\t https://github.com:foo.git (push)"
63+ mkTest " origin https://github.com:foo.git (push)"
64+ mkTest " origin\t https://github.com:foo (push)"
65+ mkTest " origin https://github.com:foo (push)"
66+ -- http
67+ mkTest " origin\t http://github.com:foo.git (push)"
68+ mkTest " origin http://github.com:foo.git (push)"
69+ mkTest " origin\t http://github.com:foo (push)"
70+ mkTest " origin http://github.com:foo (push)"
71+ -- ssh
72+ mkTest " origin\t ssh://github.com:foo.git (push)"
73+ mkTest " origin ssh://github.com:foo.git (push)"
74+ mkTest " origin\t ssh://github.com:foo (push)"
75+ mkTest " origin ssh://github.com:foo (push)"
0 commit comments