109 lines
2.6 KiB
Python
109 lines
2.6 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(
|
|
"--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(
|
|
"--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,
|
|
destination_repo_name=args.destination_repo_name,
|
|
destination_topics=args.destination_topics
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|