@@ -152,24 +152,33 @@ fn repo(remote: []const u8) ![]const u8 {
152152 if (std .mem .startsWith (u8 , remote , "https://github.com/" )) {
153153 return remote [19 .. remote .len - 4 ];
154154 }
155- if (std .mem .startsWith (u8 , remote , "git@github.com:" )) {
156- return remote [15 .. remote .len - 4 ];
155+ if (std .mem .containsAtLeast (u8 , remote , 1 , "@github.com:" )) {
156+ var splits = std .mem .splitScalar (u8 , remote , ':' );
157+ _ = splits .first ();
158+ const project = splits .next ().? ;
159+ return project [0 .. project .len - 4 ];
157160 }
158161 return error .GitProtocolMissing ;
159162}
160163
161- test "repo http" {
164+ test "repo http default " {
162165 const remote = "https://github.com/zimeg/git-coverage.git" ;
163166 const project = try repo (remote );
164167 try std .testing .expectEqualStrings (project , "zimeg/git-coverage" );
165168}
166169
167- test "repo ssh" {
170+ test "repo ssh user " {
168171 const remote = "git@github.com:zimeg/git-coverage.git" ;
169172 const project = try repo (remote );
170173 try std .testing .expectEqualStrings (project , "zimeg/git-coverage" );
171174}
172175
176+ test "repo ssh org" {
177+ const remote = "org-0123456@github.com:example/git-coverage.git" ;
178+ const project = try repo (remote );
179+ try std .testing .expectEqualStrings (project , "example/git-coverage" );
180+ }
181+
173182fn coverage (allocator : std.mem.Allocator , project : []const u8 , branch : []const u8 , path : []const u8 ) ! []const u8 {
174183 const slashes = std .mem .count (u8 , path , "/" );
175184 const encoding = try allocator .alloc (u8 , path .len + slashes * 2 );
0 commit comments