From 5059a5ceb5bb77d1f45bc8501b4509f9d8848759 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20H=C3=B6ppner?= <jonas.hoeppner@garz-fricke.com>
Date: Mon, 14 Mar 2022 12:12:25 +0100
Subject: [PATCH] CI: Add --verbose option to few scripts simplify debuging

This allows to increase the verbosity. Add --verbose in .gitlab-ci.yml
when the python script is called to view the output in the jobs log.
---
 deploy_gitlab_ci.py | 11 +++++++++++
 update_submodule.py |  9 +++++++++
 2 files changed, 20 insertions(+)

diff --git a/deploy_gitlab_ci.py b/deploy_gitlab_ci.py
index dd3de862..8a49c1c4 100755
--- a/deploy_gitlab_ci.py
+++ b/deploy_gitlab_ci.py
@@ -2,6 +2,7 @@
 import common
 
 import argparse
+import logging
 import sys
 from gitlab import Gitlab
 from accept_merge_request import accept_merge_request
@@ -57,8 +58,16 @@ def main():
         required=False,
         default=False,
     )
+    parser.add_argument(
+        "-v",
+        "--verbose",
+        action="store_true",
+        help="""Increase verbosity.""",
+    )
 
     args, _ = parser.parse_known_args()
+    if args.verbose:
+        logging.basicConfig(level=logging.DEBUG)
 
     gitlab = Gitlab(args.gitlab_url, private_token=args.token)
     project = common.get_project(gitlab, args.project)
@@ -67,6 +76,8 @@ def main():
     integration_branch, _, submodule_project = update_submodule(
         project, args.submodule, args.revision, args.branch
     )
+
+    logging.debug("Integration branch: %s", integration_branch)
     # If submodule is already at specified revision, exit successfully
     if not integration_branch:
         sys.exit(0)
diff --git a/update_submodule.py b/update_submodule.py
index 12929e20..e31bf02c 100755
--- a/update_submodule.py
+++ b/update_submodule.py
@@ -2,6 +2,7 @@
 import common
 
 import argparse
+import logging
 import os
 import sys
 import tempfile
@@ -183,8 +184,16 @@ def main():
         required=False,
         default=None,
     )
+    parser.add_argument(
+        "-v",
+        "--verbose",
+        action="store_true",
+        help="""Increase verbosity.""",
+    )
 
     args, _ = parser.parse_known_args()
+    if args.verbose:
+        logging.basicConfig(level=logging.DEBUG)
 
     gitlab = Gitlab(args.gitlab_url, private_token=args.token)
     project = common.get_project(gitlab, args.project)
-- 
GitLab