[sysadmin-bin] Improve error messages



commit 52b6a4caf6bd634a9a976c06805999564e05bc14
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date:   Thu Oct 24 08:17:07 2019 +0200

    Improve error messages

 git/post-receive-mirror-github | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/git/post-receive-mirror-github b/git/post-receive-mirror-github
index 47df5ca..e3ba372 100755
--- a/git/post-receive-mirror-github
+++ b/git/post-receive-mirror-github
@@ -215,10 +215,19 @@ def main():
             except subprocess.CalledProcessError:
                 out = open(out.name, "r")
                 err = open(err.name, "r")
-                raise Exception("Error trying to push repo %s/%s\nSTDOUT:\n%s\nSTDERR\n%s" % (organization, 
repo_name, out.read(), err.read()))
+                error_msg = """
+Error trying to push repo {}/{}
+STDOUT: {}
+STDERR: {}
+
+Command: {}
+""".format(organiation, name, out.read(), err.read(), command)
+                raise Exception(error_msg)
 
     if default_branch != 'mainline':
-        gh.update_github_repo(github_name, 'default_branch', 'mainline')
+        _, _, _, branches = gh.fetch_github_repo(github_name)
+        if "mainline" in branches:
+            gh.update_github_repo(github_name, 'default_branch', 'mainline')
 
     # Drop master branch in separate loop as GitHub API disallows to drop the
     # default branch and also expects new default branch to exists
@@ -234,7 +243,15 @@ def main():
             except subprocess.CalledProcessError:
                 out = open(out.name, "r")
                 err = open(err.name, "r")
-                raise Exception("Error trying to push repo %s/%s\nSTDOUT:\n%s\nSTDERR\n%s" % (organization, 
repo_name, out.read(), err.read()))
+                error_msg = """
+Error trying to push repo {}/{}
+STDOUT: {}
+STDERR: {}
+
+Command: {}
+""".format(organiation, name, out.read(), err.read(), command)
+                raise Exception(error_msg)
+
 
 
 if __name__ == "__main__":


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]