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,
|
2023-08-12 04:45:57 -07:00
|
|
|
help="Port of the source server. Requests will use https (not ssh), so you probably don't want to change this."
|
2023-01-17 22:14:46 -08:00
|
|
|
)
|
|
|
|
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"
|
|
|
|
)
|
2023-02-10 23:46:25 -08:00
|
|
|
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"
|
|
|
|
)
|
2023-01-17 22:14:46 -08:00
|
|
|
|
|
|
|
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,
|
2023-08-12 04:45:57 -07:00
|
|
|
help="Port of the destination server. Requests will use https (not ssh), so you probably don't want to change this."
|
2023-01-17 22:14:46 -08:00
|
|
|
)
|
|
|
|
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(
|
2023-02-11 01:25:21 -08:00
|
|
|
"--destination-add-topic", "--destination-topic", "--dest-add-topic", "--dest-topic",
|
2023-01-17 23:46:36 -08:00
|
|
|
dest="destination_topics",
|
|
|
|
default=[],
|
|
|
|
action="append",
|
|
|
|
help="Specify zero or more topics to add to each destination repository"
|
|
|
|
)
|
|
|
|
|
2023-02-11 01:25:21 -08:00
|
|
|
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."
|
|
|
|
)
|
|
|
|
|
2023-02-10 23:46:25 -08:00
|
|
|
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.",
|
|
|
|
)
|
|
|
|
|
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-08-12 04:45:57 -07:00
|
|
|
parser.add_argument(
|
|
|
|
"--ca-bundle",
|
|
|
|
dest="ca_bundle",
|
|
|
|
default=None,
|
|
|
|
help="Specify the location of your system-wide CA Bundle, in case python is not using it."
|
|
|
|
)
|
|
|
|
|
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,
|
2024-06-18 00:57:09 -07:00
|
|
|
destination_token=args.destination_token,
|
|
|
|
verify_ssl=args.verify_ssl,
|
|
|
|
ca_bundle=args.ca_bundle
|
2023-01-17 22:14:46 -08:00
|
|
|
)
|
2023-08-12 04:45:57 -07:00
|
|
|
|
2023-01-17 22:14:46 -08:00
|
|
|
mig.migrate_entire_org(
|
2023-02-10 23:46:25 -08:00
|
|
|
interactive=args.interactive,
|
2023-01-17 22:14:46 -08:00
|
|
|
source_org=args.source_org,
|
2023-02-10 23:46:25 -08:00
|
|
|
source_topics=args.source_topics,
|
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,
|
2023-02-11 01:25:21 -08:00
|
|
|
destination_topics=args.destination_topics,
|
|
|
|
do_destination_copy_topics=args.do_destination_copy_topics
|
2023-01-17 22:14:46 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|