@@ -55,6 +55,14 @@ func ReadConfigfile(configfile string) *Conf {
5555 return & t
5656}
5757
58+ func GetExcludedMap (excludes []string ) map [string ]bool {
59+ excludemap := make (map [string ]bool )
60+ for _ , exclude := range excludes {
61+ excludemap [exclude ] = true
62+ }
63+ return excludemap
64+ }
65+
5866func Locally (repo Repo , l Local ) {
5967 if _ , err := os .Stat (l .Path ); os .IsNotExist (err ) {
6068 err := os .MkdirAll (l .Path , 0777 )
@@ -288,7 +296,12 @@ func getGithub(conf *Conf) []Repo {
288296 i ++
289297 }
290298
299+ exclude := GetExcludedMap (repo .Exclude )
300+
291301 for _ , r := range githubrepos {
302+ if exclude [* r .Name ] {
303+ continue
304+ }
292305 repos = append (repos , Repo {Name : r .GetName (), Url : r .GetCloneURL (), SshUrl : r .GetSSHURL (), Token : repo .Token , Defaultbranch : r .GetDefaultBranch (), Origin : repo })
293306 }
294307 }
@@ -326,7 +339,12 @@ func getGitea(conf *Conf) []Repo {
326339 i ++
327340 }
328341
342+ exclude := GetExcludedMap (repo .Exclude )
343+
329344 for _ , r := range gitearepos {
345+ if exclude [r .Name ] {
346+ continue
347+ }
330348 repos = append (repos , Repo {Name : r .Name , Url : r .CloneURL , SshUrl : r .SSHURL , Token : repo .Token , Defaultbranch : r .DefaultBranch , Origin : repo })
331349 }
332350 }
@@ -343,7 +361,12 @@ func getGogs(conf *Conf) []Repo {
343361 log .Panic ().Str ("stage" , "gogs" ).Str ("url" , repo .Url ).Msg (err .Error ())
344362 }
345363
364+ exclude := GetExcludedMap (repo .Exclude )
365+
346366 for _ , r := range gogsrepos {
367+ if exclude [r .Name ] {
368+ continue
369+ }
347370 repos = append (repos , Repo {Name : r .Name , Url : r .CloneURL , SshUrl : r .SSHURL , Token : repo .Token , Defaultbranch : r .DefaultBranch , Origin : repo })
348371 }
349372 }
@@ -387,7 +410,13 @@ func getGitlab(conf *Conf) []Repo {
387410 }
388411 }
389412 }
413+
414+ exclude := GetExcludedMap (repo .Exclude )
415+
390416 for _ , r := range gitlabrepos {
417+ if exclude [r .Name ] {
418+ continue
419+ }
391420 repos = append (repos , Repo {Name : r .Name , Url : r .HTTPURLToRepo , SshUrl : r .SSHURLToRepo , Token : repo .Token , Defaultbranch : r .DefaultBranch , Origin : repo })
392421 }
393422 groups , _ , err := client .Groups .ListGroups (& gitlab.ListGroupsOptions {})
@@ -416,6 +445,9 @@ func getGitlab(conf *Conf) []Repo {
416445 }
417446 }
418447 for _ , r := range gitlabgrouprepos {
448+ if exclude [r .Name ] {
449+ continue
450+ }
419451 repos = append (repos , Repo {Name : r .Name , Url : r .HTTPURLToRepo , SshUrl : r .SSHURLToRepo , Token : repo .Token , Defaultbranch : r .DefaultBranch , Origin : repo })
420452 }
421453 }
@@ -442,7 +474,13 @@ func getBitbucket(conf *Conf) []Repo {
442474 if err != nil {
443475 log .Panic ().Str ("stage" , "bitbucket" ).Str ("url" , repo .Url ).Msg (err .Error ())
444476 }
477+
478+ exclude := GetExcludedMap (repo .Exclude )
479+
445480 for _ , r := range repositories .Items {
481+ if exclude [r .Name ] {
482+ continue
483+ }
446484 repos = append (repos , Repo {Name : r .Name , Url : r .Links ["clone" ].([]interface {})[0 ].(map [string ]interface {})["href" ].(string ), SshUrl : r .Links ["clone" ].([]interface {})[1 ].(map [string ]interface {})["href" ].(string ), Token : "" , Defaultbranch : r .Mainbranch .Name , Origin : repo })
447485 }
448486 }
0 commit comments