@@ -20,14 +20,7 @@ import (
2020 "gopkg.in/src-d/go-git.v2/clients/ssh"
2121)
2222
23- // ServiceFromURLFunc defines a service returning function for a given
24- // URL.
25- type ServiceFromURLFunc func (url string ) common.GitUploadPackService
26-
2723// DefaultProtocols are the protocols supported by default.
28- // Wrapping is needed because you can not cast a function that
29- // returns an implementation of an interface to a function that
30- // returns the interface.
3124var DefaultProtocols = map [string ]common.GitUploadPackService {
3225 "http" : http .NewGitUploadPackService (),
3326 "https" : http .NewGitUploadPackService (),
@@ -41,8 +34,17 @@ var KnownProtocols = make(map[string]common.GitUploadPackService, len(DefaultPro
4134
4235func init () {
4336 for k , v := range DefaultProtocols {
44- KnownProtocols [k ] = v
37+ InstallProtocol (k , v )
38+ }
39+ }
40+
41+ // InstallProtocol adds or modifies an existing protocol.
42+ func InstallProtocol (scheme string , service common.GitUploadPackService ) {
43+ if service == nil {
44+ panic ("nil service" )
4545 }
46+
47+ KnownProtocols [scheme ] = service
4648}
4749
4850// NewGitUploadPackService returns the appropiate upload pack service
@@ -60,12 +62,3 @@ func NewGitUploadPackService(repoURL string) (common.GitUploadPackService, error
6062
6163 return service , nil
6264}
63-
64- // InstallProtocol adds or modifies an existing protocol.
65- func InstallProtocol (scheme string , service common.GitUploadPackService ) {
66- if service == nil {
67- panic ("nil service" )
68- }
69-
70- KnownProtocols [scheme ] = service
71- }
0 commit comments