@@ -37,6 +37,77 @@ func TestNewGitIdentifier(t *testing.T) {
37
37
Ref : "main" ,
38
38
},
39
39
},
40
+ {
41
+ url : "git://github.com/user/repo.git" ,
42
+ expected : GitIdentifier {
43
+ Remote : "git://github.com/user/repo.git" ,
44
+ },
45
+ },
46
+ {
47
+ url : "git://github.com/user/repo.git#mybranch:mydir/mysubdir/" ,
48
+ expected : GitIdentifier {
49
+ Remote : "git://github.com/user/repo.git" ,
50
+ Ref : "mybranch" ,
51
+ Subdir : "mydir/mysubdir/" ,
52
+ },
53
+ },
54
+ {
55
+ url : "git://github.com/user/repo.git#:mydir/mysubdir/" ,
56
+ expected : GitIdentifier {
57
+ Remote : "git://github.com/user/repo.git" ,
58
+ Subdir : "mydir/mysubdir/" ,
59
+ },
60
+ },
61
+ {
62
+ url : "https://github.com/user/repo.git" ,
63
+ expected : GitIdentifier {
64
+ Remote : "https://github.com/user/repo.git" ,
65
+ },
66
+ },
67
+ {
68
+ url : "https://github.com/user/repo.git#mybranch:mydir/mysubdir/" ,
69
+ expected : GitIdentifier {
70
+ Remote : "https://github.com/user/repo.git" ,
71
+ Ref : "mybranch" ,
72
+ Subdir : "mydir/mysubdir/" ,
73
+ },
74
+ },
75
+ {
76
+ url :
"[email protected] :user/repo.git" ,
77
+ expected : GitIdentifier {
78
+ Remote :
"[email protected] :user/repo.git" ,
79
+ },
80
+ },
81
+ {
82
+ url :
"[email protected] :user/repo.git#mybranch:mydir/mysubdir/" ,
83
+ expected : GitIdentifier {
84
+ Remote :
"[email protected] :user/repo.git" ,
85
+ Ref : "mybranch" ,
86
+ Subdir : "mydir/mysubdir/" ,
87
+ },
88
+ },
89
+ {
90
+ url : "ssh://github.com/user/repo.git" ,
91
+ expected : GitIdentifier {
92
+ Remote : "ssh://github.com/user/repo.git" ,
93
+ },
94
+ },
95
+ {
96
+ url : "ssh://github.com/user/repo.git#mybranch:mydir/mysubdir/" ,
97
+ expected : GitIdentifier {
98
+ Remote : "ssh://github.com/user/repo.git" ,
99
+ Ref : "mybranch" ,
100
+ Subdir : "mydir/mysubdir/" ,
101
+ },
102
+ },
103
+ {
104
+ url :
"ssh://foo%[email protected] /user/repo.git#mybranch:mydir/mysubdir/" ,
105
+ expected : GitIdentifier {
106
+ Remote :
"ssh://foo%[email protected] /user/repo.git" ,
107
+ Ref : "mybranch" ,
108
+ Subdir : "mydir/mysubdir/" ,
109
+ },
110
+ },
40
111
}
41
112
for _ , tt := range tests {
42
113
tt := tt
0 commit comments