Skip to content

Commit 8d0684d

Browse files
committed
close #277 if i only follow the instructions in readme things do not work
1 parent 8c9e951 commit 8d0684d

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

githandler/remote.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ func OrgAndRepo(url string) *RemoteInfo {
2828
repo := splitURL[len(splitURL)-1]
2929
return &RemoteInfo{org, repo}
3030
}
31+
if strings.Contains(url, "://") {
32+
protoExp := regexp.MustCompile(`\w*:\/\/[\w.@]+(?:\:\d+)?\/(\w+)\/(\w+)\.git`)
33+
match := protoExp.FindStringSubmatch(url)
34+
return &RemoteInfo{match[1], match[2]}
35+
}
3136

3237
//Clone from local repo
3338
return &RemoteInfo{}

githandler/remote_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package githandler
33
import (
44
. "github.com/onsi/ginkgo"
55
. "github.com/onsi/gomega"
6+
"strings"
67
)
78

89
var _ = Describe("Remote", func() {
@@ -57,6 +58,40 @@ var _ = Describe("Remote", func() {
5758

5859
})
5960

61+
Context("protocol tests", func() {
62+
63+
type Case struct {
64+
Expected string
65+
Result string
66+
}
67+
68+
It("Testing with expected result set git-phlow", func() {
69+
c := Case{"[email protected]:Praqma/git-phlow.git", "Praqma:git-phlow"}
70+
Ω(OrgAndRepo(c.Expected).Organisation).Should(Equal(strings.Split(c.Result, ":")[0]))
71+
Ω(OrgAndRepo(c.Expected).Repository).Should(Equal(strings.Split(c.Result, ":")[1]))
72+
73+
})
74+
It("Testing with expected result set grit", func() {
75+
c := Case{"https://github.com/cho45/grit.git", "cho45:grit"}
76+
Ω(OrgAndRepo(c.Expected).Organisation).Should(Equal(strings.Split(c.Result, ":")[0]))
77+
Ω(OrgAndRepo(c.Expected).Repository).Should(Equal(strings.Split(c.Result, ":")[1]))
78+
79+
})
80+
It("Testing with expected result set hops", func() {
81+
c := Case{"git://github.com/koke/hops.git", "koke:hops"}
82+
Ω(OrgAndRepo(c.Expected).Organisation).Should(Equal(strings.Split(c.Result, ":")[0]))
83+
Ω(OrgAndRepo(c.Expected).Repository).Should(Equal(strings.Split(c.Result, ":")[1]))
84+
85+
})
86+
It("Testing with expected result set helmsman", func() {
87+
c := Case{"ssh://git@bitbucket:7560/praqma/helmsman.git", "praqma:helmsman"}
88+
Ω(OrgAndRepo(c.Expected).Organisation).Should(Equal(strings.Split(c.Result, ":")[0]))
89+
Ω(OrgAndRepo(c.Expected).Repository).Should(Equal(strings.Split(c.Result, ":")[1]))
90+
91+
})
92+
93+
})
94+
6095
})
6196

6297
})

0 commit comments

Comments
 (0)