Commit 6957e7e1 authored by Martin Hamant's avatar Martin Hamant 💬
Browse files

changed getGitHubGroupAvatar call location

so it's not called at every project iteration.
parent 1f7ad3fc
......@@ -109,14 +109,13 @@ def updateGitLabProjectAvatar(ghNs, gitlabProject, ghGroupAvatarData):
if not updatedProject.status_code == 200: #  201 is "created" in GitLab API
print('Error from GitLab : {}'.format(updatedProject.json()['message']))
def addProjectToGitlab(ghNs, namespace, repoName, repoUrl):
def addProjectToGitlab(ghGroupAvatarData, ghNs, namespace, repoName, repoUrl):
""" create a gitlab group name based on provided github's org/user name """
cacheGitlabGroup(namespace)
if namespace in cacheGroup:
gitlabGroupData = cacheGroup[namespace].json()
ghGroupAvatarData = getGitHubGroupAvatar(ghNs)
for project in gitlabGroupData['projects']:
if project['name'] == repoName:
......@@ -192,6 +191,7 @@ def prepareRepos(ghNs, ghRepo=None, glDestGroup=None, ghRepoOnlyList=None, doGet
# the dest group is the one read from config if specified otherwise we take
# github's namespace
dstGroup = glDestGroup if glDestGroup else ghNs
ghGroupAvatarData = getGitHubGroupAvatar(ghNs)
if ghRepo:
# get a single repo, providing a full name aka namespace/reponame
......@@ -209,7 +209,7 @@ def prepareRepos(ghNs, ghRepo=None, glDestGroup=None, ghRepoOnlyList=None, doGet
if doGetSize:
return repo['size']
addProjectToGitlab(ghNs, dstGroup,
addProjectToGitlab(ghGroupAvatarData, ghNs, dstGroup,
repo['name'], repo['clone_url'])
else:
print(repo.text)
......@@ -257,7 +257,7 @@ def prepareRepos(ghNs, ghRepo=None, glDestGroup=None, ghRepoOnlyList=None, doGet
return reposSize
# filtering against the 'only' list
if not ghRepoOnlyList or (ghRepoOnlyList and repoName in ghRepoOnlyList):
addProjectToGitlab(ghNs, dstGroup, repoName, repoUrl)
addProjectToGitlab(ghGroupAvatarData, ghNs, dstGroup, repoName, repoUrl)
else:
print(repos.text)
......@@ -266,7 +266,7 @@ def prepareRepos(ghNs, ghRepo=None, glDestGroup=None, ghRepoOnlyList=None, doGet
def prepareReposFromUrls(urls, dstGroup):
for url in urls:
repoName = url.split('/').pop().split('.')[0]
addProjectToGitlab(None, dstGroup, repoName, url)
addProjectToGitlab(None, None, dstGroup, repoName, url)
def getGitHubGroupAvatar(ghNs):
ghGroup = sessionGihubApi.get(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment