2023-01-17 22:14:46 -08:00
|
|
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
2023-01-17 23:46:36 -08:00
|
|
|
parser.add_argument(
|
|
|
|
"--destination-repo-name", "--destination-name", "--dest-repo-name", "--dest-name",
|
|
|
|
dest="destination_repo_name",
|
|
|
|
default="%N%",
|
2023-02-10 06:30:03 -08:00
|
|
|
help="Specify the destination repository name(s). Use wildcard %%N%% anywhere to denote the original name"
|
2023-01-17 23:46:36 -08:00
|
|
|
)
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
2023-01-17 22:57:31 -08:00
|
|
|
parser.add_argument(
|
|
|
|
"--no-verify-ssl",
|
|
|
|
dest="verify_ssl",
|
|
|
|
default=True,
|
|
|
|
action="store_false",
|
|
|
|
help="Don't verify SSL certificates",
|
|
|
|
)
|
|
|
|
|
2023-01-17 22:14:46 -08:00
|
|
|
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
|
|
|
|
)
|
2023-01-17 22:57:31 -08:00
|
|
|
mig.set_verify_ssl(args.verify_ssl)
|
2023-01-17 22:14:46 -08:00
|
|
|
mig.migrate_entire_org(
|
|
|
|
source_org=args.source_org,
|
2023-01-17 22:57:31 -08:00
|
|
|
destination_org=args.destination_org,
|
2023-01-17 23:46:36 -08:00
|
|
|
destination_repo_name=args.destination_repo_name,
|
|
|
|
destination_topics=args.destination_topics
|
2023-01-17 22:14:46 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|