chiark / gitweb /
server: report errors pushing to git mirrors
authorHans-Christoph Steiner <hans@eds.org>
Wed, 19 Jul 2017 11:02:06 +0000 (13:02 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 19 Jul 2017 13:07:50 +0000 (15:07 +0200)
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

fdroidserver/index.py
fdroidserver/server.py

index 86b4bb08bdbc2b3ffa09f6f706c6adedd400a9b0..b0de43251bdb871f72a3732b4220b04779831945 100644 (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
index a4ae3c85188aaf5a3488e4737ef52b955f3ec2e6..3b36eceeac96a8fc110bfa3f99ec932b9ebc1c0e 100644 (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()