@@ -43,9 +43,13 @@ var caCloneMutex sync.RWMutex
4343
4444// withExclusiveCA installs a custom HTTPS transport that trusts only caBundle
4545// (not the system cert pool) for the duration of fn, then restores the default.
46- // When caBundle is empty, fn is called under a shared lock so that default
47- // HTTPS clones cannot run while a custom-CA clone holds the write lock.
48- func withExclusiveCA (caBundle []byte , insecureSkipTLS bool , fn func () error ) error {
46+ // The mutex is only taken for HTTPS URLs because only go-git's HTTPS protocol
47+ // registry is affected; SSH and other scheme clones can proceed concurrently.
48+ func withExclusiveCA (repoURL string , caBundle []byte , insecureSkipTLS bool , fn func () error ) error {
49+ if ! strings .HasPrefix (repoURL , "https://" ) {
50+ // Non-HTTPS clone: no protocol registry mutation, no lock needed.
51+ return fn ()
52+ }
4953 if len (caBundle ) == 0 {
5054 caCloneMutex .RLock ()
5155 defer caCloneMutex .RUnlock ()
@@ -121,7 +125,7 @@ func (c *Cloner) CloneRepo(opts *GitCloner) error {
121125}
122126
123127func cloneBranch (opts * GitCloner , auth transport.AuthMethod , caBundle []byte ) error {
124- return withExclusiveCA (caBundle , opts .InsecureSkipTLS , func () error {
128+ return withExclusiveCA (opts . Repo , caBundle , opts .InsecureSkipTLS , func () error {
125129 r , err := plainClone (opts .Path , false , & git.CloneOptions {
126130 URL : opts .Repo ,
127131 Depth : 1 ,
@@ -147,7 +151,7 @@ func cloneBranch(opts *GitCloner, auth transport.AuthMethod, caBundle []byte) er
147151}
148152
149153func cloneRevision (opts * GitCloner , auth transport.AuthMethod , caBundle []byte ) error {
150- return withExclusiveCA (caBundle , opts .InsecureSkipTLS , func () error {
154+ return withExclusiveCA (opts . Repo , caBundle , opts .InsecureSkipTLS , func () error {
151155 r , err := plainClone (opts .Path , false , & git.CloneOptions {
152156 URL : opts .Repo ,
153157 Depth : 1 ,
0 commit comments