gitea-repo-migrator/main.py
2023-01-17 22:57:31 -08:00

93 lines
2.0 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(
"--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(
"--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(
source_org=args.source_org,
destination_org=args.destination_org,
)
if __name__ == "__main__":
main()