150 lines
3.8 KiB
Python
150 lines
3.8 KiB
Python
|
|
|
|
from domain.Migrator import Migrator
|
|
|
|
|
|
import argparse
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
prog="Mike's Gitea Repo Migrator - Move repositories from one Gitea instance to another"
|
|
)
|
|
|
|
parser.add_argument(
|
|
"--source-hostname", "--source-host",
|
|
dest="source_hostname",
|
|
required=True,
|
|
help="Hostname of the source server"
|
|
)
|
|
parser.add_argument(
|
|
"--source-port",
|
|
dest="source_port",
|
|
required=False,
|
|
default=None,
|
|
help="Port of the source server"
|
|
)
|
|
parser.add_argument(
|
|
"--source-token",
|
|
dest="source_token",
|
|
required=True,
|
|
help="Provide an API token for the source Gitea instance's user"
|
|
)
|
|
parser.add_argument(
|
|
"--source-org",
|
|
dest="source_org",
|
|
required=True,
|
|
help="Name of the source organization"
|
|
)
|
|
parser.add_argument(
|
|
"--source-required-topic", "--source-topic",
|
|
dest="source_topics",
|
|
default=[],
|
|
action="append",
|
|
help="Specify zero or more topics required topics for source repositories."
|
|
" Any repository that doesn't have all required topics will be skipped"
|
|
)
|
|
|
|
parser.add_argument(
|
|
"--destination-hostname", "--dest-hostname", "--destination-host", "--dest-host",
|
|
dest="destination_hostname",
|
|
required=True,
|
|
help="Hostname of the destination server"
|
|
)
|
|
parser.add_argument(
|
|
"--destination-port", "--dest-port",
|
|
dest="destination_port",
|
|
required=False,
|
|
default=None,
|
|
help="Port of the destination server"
|
|
)
|
|
parser.add_argument(
|
|
"--destination-token", "--dest-token",
|
|
dest="destination_token",
|
|
required=True,
|
|
help="Provide an API token for the destination Gitea instance's user"
|
|
)
|
|
parser.add_argument(
|
|
"--destination-org", "--dest-org",
|
|
dest="destination_org",
|
|
required=True,
|
|
help="Name of the destination organization"
|
|
)
|
|
|
|
parser.add_argument(
|
|
"--destination-repo-name", "--destination-name", "--dest-repo-name", "--dest-name",
|
|
dest="destination_repo_name",
|
|
default="%N%",
|
|
help="Specify the destination repository name(s). Use wildcard %%N%% anywhere to denote the original name"
|
|
)
|
|
parser.add_argument(
|
|
"--destination-add-topic", "--destination-topic", "--dest-add-topic", "--dest-topic",
|
|
dest="destination_topics",
|
|
default=[],
|
|
action="append",
|
|
help="Specify zero or more topics to add to each destination repository"
|
|
)
|
|
|
|
parser.add_argument(
|
|
"--destination-copy-topics", "--dest-copy-topics",
|
|
dest="do_destination_copy_topics",
|
|
default=True,
|
|
action="store_true",
|
|
help="Destination repos should copy topics from their source."
|
|
)
|
|
parser.add_argument(
|
|
"--no-destination-copy-topics", "--no-dest-copy-topics",
|
|
dest="do_destination_copy_topics",
|
|
default=True,
|
|
action="store_false",
|
|
help="Destination repos should NOT copy topics from their source."
|
|
)
|
|
|
|
parser.add_argument(
|
|
"--interactive",
|
|
dest="interactive",
|
|
default=True,
|
|
action="store_true",
|
|
help="Ask to confirm each migration.",
|
|
)
|
|
parser.add_argument(
|
|
"--no-interactive", "--non-interactive",
|
|
dest="interactive",
|
|
default=True,
|
|
action="store_false",
|
|
help="Do not ask to confirm each migration; Migrate all repos quickly.",
|
|
)
|
|
|
|
parser.add_argument(
|
|
"--no-verify-ssl",
|
|
dest="verify_ssl",
|
|
default=True,
|
|
action="store_false",
|
|
help="Don't verify SSL certificates",
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
mig = Migrator(
|
|
source_host=args.source_hostname,
|
|
source_port=args.source_port,
|
|
source_token=args.source_token,
|
|
destination_host=args.destination_hostname,
|
|
destination_port=args.destination_port,
|
|
destination_token=args.destination_token
|
|
)
|
|
mig.set_verify_ssl(args.verify_ssl)
|
|
mig.migrate_entire_org(
|
|
interactive=args.interactive,
|
|
source_org=args.source_org,
|
|
source_topics=args.source_topics,
|
|
destination_org=args.destination_org,
|
|
destination_repo_name=args.destination_repo_name,
|
|
destination_topics=args.destination_topics,
|
|
do_destination_copy_topics=args.do_destination_copy_topics
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|