@@ -104,7 +104,7 @@ type pathDeducer interface {
104
104
// So the return of the above string would be
105
105
// "github.com/some-user/some-package"
106
106
deduceRoot (string ) (string , error )
107
- deduceSource (string , * url.URL ) (maybeSource , error )
107
+ deduceSource (string , * url.URL ) (maybeSources , error )
108
108
}
109
109
110
110
type githubDeducer struct {
@@ -120,7 +120,7 @@ func (m githubDeducer) deduceRoot(path string) (string, error) {
120
120
return "github.com" + v [2 ], nil
121
121
}
122
122
123
- func (m githubDeducer ) deduceSource (path string , u * url.URL ) (maybeSource , error ) {
123
+ func (m githubDeducer ) deduceSource (path string , u * url.URL ) (maybeSources , error ) {
124
124
v := m .regexp .FindStringSubmatch (path )
125
125
if v == nil {
126
126
return nil , fmt .Errorf ("%s is not a valid path for a source on github.com" , path )
@@ -138,7 +138,7 @@ func (m githubDeducer) deduceSource(path string, u *url.URL) (maybeSource, error
138
138
if u .Scheme == "ssh" {
139
139
u .User = url .User ("git" )
140
140
}
141
- return maybeGitSource {url : u }, nil
141
+ return maybeSources { maybeGitSource {url : u } }, nil
142
142
}
143
143
144
144
mb := make (maybeSources , len (gitSchemes ))
@@ -167,7 +167,7 @@ func (m bitbucketDeducer) deduceRoot(path string) (string, error) {
167
167
return "bitbucket.org" + v [2 ], nil
168
168
}
169
169
170
- func (m bitbucketDeducer ) deduceSource (path string , u * url.URL ) (maybeSource , error ) {
170
+ func (m bitbucketDeducer ) deduceSource (path string , u * url.URL ) (maybeSources , error ) {
171
171
v := m .regexp .FindStringSubmatch (path )
172
172
if v == nil {
173
173
return nil , fmt .Errorf ("%s is not a valid path for a source on bitbucket.org" , path )
@@ -189,12 +189,12 @@ func (m bitbucketDeducer) deduceSource(path string, u *url.URL) (maybeSource, er
189
189
// superset of the hg schemes
190
190
return nil , fmt .Errorf ("%s is not a valid scheme for accessing a git repository" , u .Scheme )
191
191
}
192
- return maybeGitSource {url : u }, nil
192
+ return maybeSources { maybeGitSource {url : u } }, nil
193
193
} else if ishg {
194
194
if ! validhg {
195
195
return nil , fmt .Errorf ("%s is not a valid scheme for accessing an hg repository" , u .Scheme )
196
196
}
197
- return maybeHgSource {url : u }, nil
197
+ return maybeSources { maybeHgSource {url : u } }, nil
198
198
} else if ! validgit && ! validhg {
199
199
return nil , fmt .Errorf ("%s is not a valid scheme for accessing either a git or hg repository" , u .Scheme )
200
200
}
@@ -265,7 +265,7 @@ func (m gopkginDeducer) parseAndValidatePath(p string) ([]string, error) {
265
265
return v , nil
266
266
}
267
267
268
- func (m gopkginDeducer ) deduceSource (p string , u * url.URL ) (maybeSource , error ) {
268
+ func (m gopkginDeducer ) deduceSource (p string , u * url.URL ) (maybeSources , error ) {
269
269
// Reuse root detection logic for initial validation
270
270
v , err := m .parseAndValidatePath (p )
271
271
if err != nil {
@@ -329,7 +329,7 @@ func (m launchpadDeducer) deduceRoot(path string) (string, error) {
329
329
return "launchpad.net" + v [2 ], nil
330
330
}
331
331
332
- func (m launchpadDeducer ) deduceSource (path string , u * url.URL ) (maybeSource , error ) {
332
+ func (m launchpadDeducer ) deduceSource (path string , u * url.URL ) (maybeSources , error ) {
333
333
v := m .regexp .FindStringSubmatch (path )
334
334
if v == nil {
335
335
return nil , fmt .Errorf ("%s is not a valid path for a source on launchpad.net" , path )
@@ -342,7 +342,7 @@ func (m launchpadDeducer) deduceSource(path string, u *url.URL) (maybeSource, er
342
342
if ! validateVCSScheme (u .Scheme , "bzr" ) {
343
343
return nil , fmt .Errorf ("%s is not a valid scheme for accessing a bzr repository" , u .Scheme )
344
344
}
345
- return maybeBzrSource {url : u }, nil
345
+ return maybeSources { maybeBzrSource {url : u } }, nil
346
346
}
347
347
348
348
mb := make (maybeSources , len (bzrSchemes ))
@@ -369,7 +369,7 @@ func (m launchpadGitDeducer) deduceRoot(path string) (string, error) {
369
369
return "git.launchpad.net" + v [2 ], nil
370
370
}
371
371
372
- func (m launchpadGitDeducer ) deduceSource (path string , u * url.URL ) (maybeSource , error ) {
372
+ func (m launchpadGitDeducer ) deduceSource (path string , u * url.URL ) (maybeSources , error ) {
373
373
v := m .regexp .FindStringSubmatch (path )
374
374
if v == nil {
375
375
return nil , fmt .Errorf ("%s is not a valid path for a source on git.launchpad.net" , path )
@@ -382,7 +382,7 @@ func (m launchpadGitDeducer) deduceSource(path string, u *url.URL) (maybeSource,
382
382
if ! validateVCSScheme (u .Scheme , "git" ) {
383
383
return nil , fmt .Errorf ("%s is not a valid scheme for accessing a git repository" , u .Scheme )
384
384
}
385
- return maybeGitSource {url : u }, nil
385
+ return maybeSources { maybeGitSource {url : u } }, nil
386
386
}
387
387
388
388
mb := make (maybeSources , len (gitSchemes ))
@@ -408,7 +408,7 @@ func (m jazzDeducer) deduceRoot(path string) (string, error) {
408
408
return "hub.jazz.net" + v [2 ], nil
409
409
}
410
410
411
- func (m jazzDeducer ) deduceSource (path string , u * url.URL ) (maybeSource , error ) {
411
+ func (m jazzDeducer ) deduceSource (path string , u * url.URL ) (maybeSources , error ) {
412
412
v := m .regexp .FindStringSubmatch (path )
413
413
if v == nil {
414
414
return nil , fmt .Errorf ("%s is not a valid path for a source on hub.jazz.net" , path )
@@ -422,7 +422,7 @@ func (m jazzDeducer) deduceSource(path string, u *url.URL) (maybeSource, error)
422
422
u .Scheme = "https"
423
423
fallthrough
424
424
case "https" :
425
- return maybeGitSource {url : u }, nil
425
+ return maybeSources { maybeGitSource {url : u } }, nil
426
426
default :
427
427
return nil , fmt .Errorf ("IBM's jazz hub only supports https, %s is not allowed" , u .String ())
428
428
}
@@ -441,7 +441,7 @@ func (m apacheDeducer) deduceRoot(path string) (string, error) {
441
441
return "git.apache.org" + v [2 ], nil
442
442
}
443
443
444
- func (m apacheDeducer ) deduceSource (path string , u * url.URL ) (maybeSource , error ) {
444
+ func (m apacheDeducer ) deduceSource (path string , u * url.URL ) (maybeSources , error ) {
445
445
v := m .regexp .FindStringSubmatch (path )
446
446
if v == nil {
447
447
return nil , fmt .Errorf ("%s is not a valid path for a source on git.apache.org" , path )
@@ -454,7 +454,7 @@ func (m apacheDeducer) deduceSource(path string, u *url.URL) (maybeSource, error
454
454
if ! validateVCSScheme (u .Scheme , "git" ) {
455
455
return nil , fmt .Errorf ("%s is not a valid scheme for accessing a git repository" , u .Scheme )
456
456
}
457
- return maybeGitSource {url : u }, nil
457
+ return maybeSources { maybeGitSource {url : u } }, nil
458
458
}
459
459
460
460
mb := make (maybeSources , len (gitSchemes ))
@@ -480,7 +480,7 @@ func (m vcsExtensionDeducer) deduceRoot(path string) (string, error) {
480
480
return v [1 ], nil
481
481
}
482
482
483
- func (m vcsExtensionDeducer ) deduceSource (path string , u * url.URL ) (maybeSource , error ) {
483
+ func (m vcsExtensionDeducer ) deduceSource (path string , u * url.URL ) (maybeSources , error ) {
484
484
v := m .regexp .FindStringSubmatch (path )
485
485
if v == nil {
486
486
return nil , fmt .Errorf ("%s contains no vcs extension hints for matching" , path )
@@ -500,11 +500,11 @@ func (m vcsExtensionDeducer) deduceSource(path string, u *url.URL) (maybeSource,
500
500
501
501
switch v [4 ] {
502
502
case "git" :
503
- return maybeGitSource {url : u }, nil
503
+ return maybeSources { maybeGitSource {url : u } }, nil
504
504
case "bzr" :
505
- return maybeBzrSource {url : u }, nil
505
+ return maybeSources { maybeBzrSource {url : u } }, nil
506
506
case "hg" :
507
- return maybeHgSource {url : u }, nil
507
+ return maybeSources { maybeHgSource {url : u } }, nil
508
508
}
509
509
}
510
510
@@ -590,7 +590,7 @@ func (dc *deductionCoordinator) deduceRootPath(ctx context.Context, path string)
590
590
dc .mut .RUnlock ()
591
591
if has && isPathPrefixOrEqual (prefix , path ) {
592
592
switch d := data .(type ) {
593
- case maybeSource :
593
+ case maybeSources :
594
594
return pathDeduction {root : prefix , mb : d }, nil
595
595
case * httpMetadataDeducer :
596
596
// Multiple calls have come in for a similar path shape during
@@ -652,7 +652,7 @@ func (dc *deductionCoordinator) deduceRootPath(ctx context.Context, path string)
652
652
// the source.
653
653
type pathDeduction struct {
654
654
root string
655
- mb maybeSource
655
+ mb maybeSources
656
656
}
657
657
658
658
var errNoKnownPathMatch = errors .New ("no known path match" )
@@ -759,11 +759,11 @@ func (hmd *httpMetadataDeducer) deduce(ctx context.Context, path string) (pathDe
759
759
760
760
switch vcs {
761
761
case "git" :
762
- pd .mb = maybeGitSource {url : repoURL }
762
+ pd .mb = maybeSources { maybeGitSource {url : repoURL } }
763
763
case "bzr" :
764
- pd .mb = maybeBzrSource {url : repoURL }
764
+ pd .mb = maybeSources { maybeBzrSource {url : repoURL } }
765
765
case "hg" :
766
- pd .mb = maybeHgSource {url : repoURL }
766
+ pd .mb = maybeSources { maybeHgSource {url : repoURL } }
767
767
default :
768
768
hmd .deduceErr = errors .Errorf ("unsupported vcs type %s in go-get metadata from %s" , vcs , path )
769
769
return
0 commit comments