trying to upgrade the giteapy version, bleh
This commit is contained in:
parent
34c77b5069
commit
481e85a533
1
Pipfile
1
Pipfile
@ -4,7 +4,6 @@ verify_ssl = true
|
|||||||
name = "pypi"
|
name = "pypi"
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
giteapy = "*"
|
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
||||||
|
44
Pipfile.lock
generated
44
Pipfile.lock
generated
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "824c02127733d501ae21f3e5ccc7ee72fc4b2fe92bbca23c77ebd204d294b0fc"
|
"sha256": "fedbd2ab7afd84cf16f128af0619749267b62277b4cb6989ef16d4bef6e4eef2"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -15,46 +15,6 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"default": {
|
"default": {},
|
||||||
"certifi": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3",
|
|
||||||
"sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '3.6'",
|
|
||||||
"version": "==2022.12.7"
|
|
||||||
},
|
|
||||||
"giteapy": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:2078c802a4626bf311e911c969c34b7d19fbe9175e2910e1965b24ff69221470"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==1.0.8"
|
|
||||||
},
|
|
||||||
"python-dateutil": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
|
|
||||||
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
|
||||||
"version": "==2.8.2"
|
|
||||||
},
|
|
||||||
"six": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
|
|
||||||
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
|
||||||
"version": "==1.16.0"
|
|
||||||
},
|
|
||||||
"urllib3": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:076907bf8fd355cde77728471316625a4d2f7e713c125f51953bb5b3eecf4f72",
|
|
||||||
"sha256:75edcdc2f7d85b137124a6c3c9fc3933cdeaa12ecb9a6a959f22797a0feca7e1"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'",
|
|
||||||
"version": "==1.26.14"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"develop": {}
|
"develop": {}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import giteapy
|
# import giteapy
|
||||||
|
import giteapy.giteapy
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -103,13 +104,22 @@ class Migrator:
|
|||||||
|
|
||||||
def migrate_entire_org(
|
def migrate_entire_org(
|
||||||
self,
|
self,
|
||||||
source_org: str,
|
interactive: bool = True,
|
||||||
destination_org: str, destination_repo_name: str, destination_topics: list
|
source_org: str = None, source_topics: list[str] = None,
|
||||||
|
destination_org: str = None, destination_repo_name: str = None, destination_topics: list = None
|
||||||
):
|
):
|
||||||
|
assert source_org is not None, "Source org must be specified"
|
||||||
|
assert destination_org is not None, "Destination org must be specified"
|
||||||
|
assert destination_repo_name is not None, "Destination repo name must be specified"
|
||||||
|
assert destination_topics is not None, "Destination topics must be specified"
|
||||||
|
|
||||||
api_source, api_destination = self._get_org_apis()
|
api_source, api_destination = self._get_org_apis()
|
||||||
|
api_source: giteapy.OrganizationApi
|
||||||
|
api_destination: giteapy.OrganizationApi
|
||||||
|
|
||||||
source_repos = api_source.org_list_repos(source_org)
|
api_source_repos = self._get_repo_api(hostname=self.__source_host, port=self.__source_port, token=self.__source_token)
|
||||||
|
|
||||||
|
source_repos = api_source.org_list_repos(source_org, page=0, limit=1000000)
|
||||||
self.__logger.info(f"Found {len(source_repos)} repos on source:")
|
self.__logger.info(f"Found {len(source_repos)} repos on source:")
|
||||||
for repo in source_repos:
|
for repo in source_repos:
|
||||||
repo: giteapy.Repository
|
repo: giteapy.Repository
|
||||||
@ -124,10 +134,27 @@ class Migrator:
|
|||||||
|
|
||||||
repo: giteapy.Repository
|
repo: giteapy.Repository
|
||||||
|
|
||||||
|
repo_topics = api_source_repos.repo_list_topics(owner=repo.owner.login, repo=repo.name)
|
||||||
|
repo_topics = repo_topics.topics
|
||||||
|
self.__logger.error(f"Repo topics: {repo_topics}")
|
||||||
|
|
||||||
|
if self._check_source_repo_topics(repo=repo, topics=source_topics) is False:
|
||||||
|
repos_ignore.append(repo)
|
||||||
|
self.__logger.info(
|
||||||
|
f"Ignoring repo because it doesn't have all required tags."
|
||||||
|
f"\n> Repo: {repo.full_name}"
|
||||||
|
f"\n> Has: {repo_topics}"
|
||||||
|
f"\n> Needs: {source_topics}"
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
response = input(f"Migrate repo #{repo.id} \"{repo.full_name}\" ? (Y)es, (N)o, (G)o right now, (Q)uit ==> ")
|
if interactive:
|
||||||
response = response.lower()
|
response = input(f"Migrate repo #{repo.id} \"{repo.full_name}\" ? (Y)es, (N)o, (G)o right now, (Q)uit ==> ")
|
||||||
|
response = response.lower()
|
||||||
|
else:
|
||||||
|
response = "y"
|
||||||
|
|
||||||
valid_input = True
|
valid_input = True
|
||||||
if response == "y":
|
if response == "y":
|
||||||
@ -192,6 +219,10 @@ class Migrator:
|
|||||||
else:
|
else:
|
||||||
self.__logger.info("Confirmation not received; Won't do anything.")
|
self.__logger.info("Confirmation not received; Won't do anything.")
|
||||||
|
|
||||||
|
def _check_source_repo_topics(self, repo: giteapy.Repository, topics: list[str]) -> bool:
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def _migrate_repos(
|
def _migrate_repos(
|
||||||
self,
|
self,
|
||||||
destination_org_name: str,
|
destination_org_name: str,
|
||||||
|
1
giteapy
Submodule
1
giteapy
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit e0a089bdfb7ef6130b43727c50e78f176379db20
|
25
main.py
25
main.py
@ -37,6 +37,14 @@ def main():
|
|||||||
required=True,
|
required=True,
|
||||||
help="Name of the source organization"
|
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(
|
parser.add_argument(
|
||||||
"--destination-hostname", "--dest-hostname", "--destination-host", "--dest-host",
|
"--destination-hostname", "--dest-hostname", "--destination-host", "--dest-host",
|
||||||
@ -78,6 +86,21 @@ def main():
|
|||||||
help="Specify zero or more topics to add to each destination repository"
|
help="Specify zero or more topics to add to each destination repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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(
|
parser.add_argument(
|
||||||
"--no-verify-ssl",
|
"--no-verify-ssl",
|
||||||
dest="verify_ssl",
|
dest="verify_ssl",
|
||||||
@ -97,7 +120,9 @@ def main():
|
|||||||
)
|
)
|
||||||
mig.set_verify_ssl(args.verify_ssl)
|
mig.set_verify_ssl(args.verify_ssl)
|
||||||
mig.migrate_entire_org(
|
mig.migrate_entire_org(
|
||||||
|
interactive=args.interactive,
|
||||||
source_org=args.source_org,
|
source_org=args.source_org,
|
||||||
|
source_topics=args.source_topics,
|
||||||
destination_org=args.destination_org,
|
destination_org=args.destination_org,
|
||||||
destination_repo_name=args.destination_repo_name,
|
destination_repo_name=args.destination_repo_name,
|
||||||
destination_topics=args.destination_topics
|
destination_topics=args.destination_topics
|
||||||
|
Loading…
Reference in New Issue
Block a user