Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #105 #106

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions hub-mirror/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def __init__(
self.dst_type, self.dst_account = dst.split('/')
self.dst_token = dst_token
self.session = requests.Session()
self.all_dst_repo_list = []
if self.dst_type == "gitee":
self.dst_base = 'https://gitee.com/api/v5'
elif self.dst_type == "github":
Expand All @@ -33,15 +34,19 @@ def __init__(
prefix = "git@" + self.dst_type + ".com:"
self.dst_repo_base = prefix + self.dst_account

def has_dst_repo(self, repo_name):
def make_dst_repo_list(self):
url = '/'.join(
[self.dst_base, self.account_type+'s', self.dst_account, 'repos']
)
repo_names = self._get_all_repo_names(url)
if not repo_names:
return self._get_all_repo_names(url)

def has_dst_repo(self, repo_name):
if not self.all_dst_repo_list:
self.all_dst_repo_list = self.make_dst_repo_list()
if not self.all_dst_repo_list:
print("Warning: destination repos is []")
return False
return repo_name in repo_names
return repo_name in self.all_dst_repo_list

def create_dst_repo(self, repo_name):
suffix = 'user/repos'
Expand Down