MigratePrivatebool`flag:"migrate-private" default:"true" description:"Migrate private repos (the given Github Token will be entered as sync credential!)"`
SourceExpressionstring`flag:"source-expression" default:"" description:"Regular expression to match the full name of the source repo (i.e. '^Luzifer/.*$')" validate:"nonzero"`
TargetUserint64`flag:"target-user" default:"0" description:"ID of the User / Organization in Gitea to assign the repo to" validate:"nonzero"`
TargetUserNamestring`flag:"target-user-name" default:"" description:"Username of the given ID (to check whether repo already exists)" validate:"nonzero"`
VersionAndExitbool`flag:"version" default:"false" description:"Prints current version and exits"`
}{}
version="dev"
)
funcinit(){
rconfig.AutoEnv(true)
iferr:=rconfig.ParseAndValidate(&cfg);err!=nil{
log.Fatalf("Unable to parse commandline options: %s",err)
}
ifcfg.VersionAndExit{
fmt.Printf("create-gitea-migration %s\n",version)
os.Exit(0)
}
ifl,err:=log.ParseLevel(cfg.LogLevel);err!=nil{
log.WithError(err).Fatal("Unable to parse log level")
}else{
log.SetLevel(l)
}
}
funcmain(){
log.WithFields(log.Fields{
"dry-run":cfg.DryRun,
"source":cfg.SourceExpression,
"target-user":cfg.TargetUserName,
"version":version,
}).Info("create-gitea-migration started")
log.Info("Collecting source repos...")
repos,err:=fetchGithubRepos()
iferr!=nil{
log.WithError(err).Fatal("Failed to fetch repos")
}
log.Info("Creating target repos...")
for_,r:=rangerepos{
iferr:=giteaCreateMigration(r);err!=nil{
log.WithError(err).Error("Unable to create mirror")