server: report errors pushing to git mirrors

This makes `fdroid server update` fail if pushing to one of the git mirrors
fails.  This is what happens if the other methods fail, e.g. rsync or S3.

closes #347
This commit is contained in:
Hans-Christoph Steiner 2017-07-19 13:02:06 +02:00
parent 93caf27319
commit 1f7f9d403c
2 changed files with 10 additions and 9 deletions

View file

@ -567,7 +567,6 @@ def get_mirror_service_urls(url):
return urls
def download_repo_index(url_str, etag=None, verify_fingerprint=True):
"""
Downloads the repository index from the given :param url_str

View file

@ -386,7 +386,6 @@ def update_servergitmirrors(servergitmirrors, repo_section):
# push for every remote. This will overwrite the git history
for remote in repo.remotes:
branch = 'master'
if remote.name == 'gitlab':
logging.debug('Writing .gitlab-ci.yml to deploy to GitLab Pages')
with open(os.path.join(git_mirror_path, ".gitlab-ci.yml"), "wt") as out_file:
@ -405,13 +404,16 @@ def update_servergitmirrors(servergitmirrors, repo_section):
logging.debug('Pushing to ' + remote.url)
with repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd):
remote.push(branch, force=True, set_upstream=True, progress=progress)
# Reset the gitlab specific stuff before the next remote.
if remote.name == 'gitlab':
logging.debug('Removing .gitlab-ci.yml now that it has successfully deployed')
repo.index.reset('HEAD^')
repo.index.checkout(force=True)
pushinfos = remote.push('master', force=True, set_upstream=True, progress=progress)
for pushinfo in pushinfos:
if pushinfo.flags & (git.remote.PushInfo.ERROR
| git.remote.PushInfo.REJECTED
| git.remote.PushInfo.REMOTE_FAILURE
| git.remote.PushInfo.REMOTE_REJECTED):
raise FDroidException(remote.url + ' push failed: ' + str(pushinfo.flags)
+ ' ' + pushinfo.summary)
else:
logging.debug(remote.url + ': ' + pushinfo.summary)
if progress:
bar.done()