Commit 3ff09cc6 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

gh: more await

parent c8afda8a
Pipeline #15356 failed with stage
in 9 seconds
......@@ -92,7 +92,8 @@ async def pull_request(request: HttpRequest, rep: str) -> HttpResponse:
# Create a gitlab remote if it doesn't exist
gl_remote_name = f'gitlab/{namespace.slug}'
if gl_remote_name not in git_repo.remotes:
await sync_to_async(git_repo.create_remote)(gl_remote_name, url=project.remote_url_gitlab())
url = awaint sync_to_async(project.remote_url_gitlab)()
await sync_to_async(git_repo.create_remote)(gl_remote_name, url=url)
# Push the changes to gitlab
logger.info(f'{namespace.slug}/{project.slug}: Pushing {commit} on {branch} on gitlab')
......@@ -150,14 +151,16 @@ async def push(request: HttpRequest, source: SOURCES, rep: str) -> HttpResponse:
if gl_remote_name in git_repo.remotes:
gl_remote = await sync_to_async(git_repo.remote)(gl_remote_name)
else:
gl_remote = await sync_to_async(git_repo.create_remote)(gl_remote_name, url=project.remote_url_gitlab())
url = awaint sync_to_async(project.remote_url_gitlab)()
gl_remote = await sync_to_async(git_repo.create_remote)(gl_remote_name, url=url)
gl_remote.fetch()
# Fetch the latest commit from github
if gh_remote_name in git_repo.remotes:
gh_remote = await sync_to_async(git_repo.remote)(gh_remote_name)
else:
gh_remote = await sync_to_async(git_repo.create_remote)(gh_remote_name, url=project.remote_url_github())
url = awaint sync_to_async(project.remote_url_github)()
gh_remote = await sync_to_async(git_repo.create_remote)(gh_remote_name, url=url)
gh_remote.fetch()
# The branch was deleted on one remote, delete the branch on the other remote as well
......
Markdown is supported
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