@@ -537,48 +537,35 @@ func normalizeDebianProgramName(str string) string {
537
537
}
538
538
539
539
func shortHostName (gopkg string , allowUnknownHoster bool ) (host string , err error ) {
540
+
541
+ knownHosts := map [string ]string {
542
+ "github.com" : "github" ,
543
+ "code.google.com" : "googlecode" ,
544
+ "cloud.google.com" : "googlecloud" ,
545
+ "gopkg.in" : "gopkg" ,
546
+ "golang.org" : "golang" ,
547
+ "google.golang.org" : "google" ,
548
+ "gitlab.com" : "gitlab" ,
549
+ "bitbucket.org" : "bitbucket" ,
550
+ "bazil.org" : "bazil" ,
551
+ "blitiri.com.ar" : "blitiri" ,
552
+ "pault.ag" : "pault" ,
553
+ "howett.net" : "howett" ,
554
+ "go4.org" : "go4" ,
555
+ "salsa.debian.org" : "debian" ,
556
+ }
540
557
parts := strings .Split (gopkg , "/" )
541
558
fqdn := parts [0 ]
542
-
543
- switch fqdn {
544
- case "github.com" :
545
- host = "github"
546
- case "code.google.com" :
547
- host = "googlecode"
548
- case "cloud.google.com" :
549
- host = "googlecloud"
550
- case "gopkg.in" :
551
- host = "gopkg"
552
- case "golang.org" :
553
- host = "golang"
554
- case "google.golang.org" :
555
- host = "google"
556
- case "gitlab.com" :
557
- host = "gitlab"
558
- case "bitbucket.org" :
559
- host = "bitbucket"
560
- case "bazil.org" :
561
- host = "bazil"
562
- case "blitiri.com.ar" :
563
- host = "blitiri"
564
- case "pault.ag" :
565
- host = "pault"
566
- case "howett.net" :
567
- host = "howett"
568
- case "go4.org" :
569
- host = "go4"
570
- case "salsa.debian.org" :
571
- host = "debian"
572
- default :
573
- if allowUnknownHoster {
574
- suffix , _ := publicsuffix .PublicSuffix (host )
575
- host = fqdn [:len (fqdn )- len (suffix )- len ("." )]
576
- log .Printf ("WARNING: Using %q as canonical hostname for %q. If that is not okay, please file a bug against %s.\n " , host , fqdn , os .Args [0 ])
577
- } else {
578
- err = fmt .Errorf ("unknown hoster %q" , fqdn )
579
- }
559
+ if host , ok := knownHosts [fqdn ]; ok {
560
+ return host , nil
561
+ }
562
+ if ! allowUnknownHoster {
563
+ return "" , fmt .Errorf ("unknown hoster %q" , fqdn )
580
564
}
581
- return host , err
565
+ suffix , _ := publicsuffix .PublicSuffix (fqdn )
566
+ host = fqdn [:len (fqdn )- len (suffix )- len ("." )]
567
+ log .Printf ("WARNING: Using %q as canonical hostname for %q. If that is not okay, please file a bug against %s.\n " , host , fqdn , os .Args [0 ])
568
+ return host , nil
582
569
}
583
570
584
571
// debianNameFromGopkg maps a Go package repo path to a Debian package name,
0 commit comments