From 1a5272283d7cef3d89a830dc897ea035c894a731 Mon Sep 17 00:00:00 2001
From: Knut Ahlers <knut@ahlers.me>
Date: Sat, 27 Jul 2019 09:55:30 +0200
Subject: [PATCH] Add flag for not migrating forks

---
 main.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/main.go b/main.go
index cd69a75..d40dc26 100644
--- a/main.go
+++ b/main.go
@@ -26,6 +26,7 @@ var (
 		GithubToken      string `flag:"github-token" default:"" description:"Github access token" validate:"nonzero"`
 		LogLevel         string `flag:"log-level" default:"info" description:"Log level (debug, info, warn, error, fatal)"`
 		MigrateArchived  bool   `flag:"migrate-archived" default:"false" description:"Create migrations for archived repos"`
+		MigrateForks     bool   `flag:"migrate-forks" default:"false" description:"Create migrations for forked repos"`
 		MigratePrivate   bool   `flag:"migrate-private" default:"true" description:"Migrate private repos (the given Github Token will be entered as sync credential!)"`
 		SourceExpression string `flag:"source-expression" default:"" description:"Regular expression to match the full name of the source repo (i.e. '^Luzifer/.*$')" validate:"nonzero"`
 		TargetUser       int64  `flag:"target-user" default:"0" description:"ID of the User / Organization in Gitea to assign the repo to" validate:"nonzero"`
@@ -111,6 +112,11 @@ func fetchGithubRepos() ([]*github.Repository, error) {
 				continue
 			}
 
+			if !cfg.MigrateForks && boolFromPtr(r.Fork) {
+				log.WithField("repo", *r.FullName).Debug("Skip: Fork")
+				continue
+			}
+
 			allRepos = append(allRepos, r)
 		}