Browse Source

Couple of fixes for the mirroring-in feature

This commit does a couple of fixes in the code used for the mirroring-in
feature.
It ensures any exception thrown by pagure.lib.git.mirror_pull_project are
caught and properly logged. Otherwise, the script dies in the middle of
the processing.
It also checks that there is a remote before doing anything and if there
is no remote, it just bails.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Pierre-Yves Chibon 5 years ago
parent
commit
cea8e24f3e
2 changed files with 7 additions and 1 deletions
  1. 4 1
      files/mirror_project_in.py
  2. 3 0
      pagure/lib/git.py

+ 4 - 1
files/mirror_project_in.py

@@ -34,7 +34,10 @@ def main(check=False, debug=False):
     for project in projects:
         if debug:
             print("Mirrorring %s" % project.fullname)
-        pagure.lib.git.mirror_pull_project(session, project, debug=debug)
+        try:
+            pagure.lib.git.mirror_pull_project(session, project, debug=debug)
+        except Exception as err:
+            print("ERROR: %s" % err)
 
     session.remove()
     if debug:

+ 3 - 0
pagure/lib/git.py

@@ -2846,6 +2846,9 @@ def generate_archive(project, commit, tag, name, archive_fmt):
 def mirror_pull_project(session, project, debug=False):
     """ Mirror locally a project from a remote URL. """
     remote = project.mirrored_from
+    if not remote:
+        _log.info("No remote found, ignoring")
+        return
     repopath = tempfile.mkdtemp(prefix="pagure-mirror_in-")
     lclrepopath = pagure.utils.get_repo_path(project)