From 285ce1951cc2ce2f6a0c390a6ece5042d930e95a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20H=C3=B6ppner?= <jonas.hoeppner@garz-fricke.com>
Date: Fri, 25 Mar 2022 13:27:24 +0100
Subject: [PATCH] CI: Merge_into_manifest: Fixes for merge detection

---
 .gitlab-ci.yml                  | 18 +++++++++++-------
 common.yml                      |  1 +
 foobar-manifest-integration.yml |  1 +
 merge_into_manifest.py          | 12 +++++++++++-
 4 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5a13d3f..c81a929 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -125,6 +125,8 @@ deploy:
   extends:
     - .deploy
     - .manifest-projects
+  rules:
+    - when: never
 
 deploy-foobar:
   extends:
@@ -134,6 +136,7 @@ deploy-foobar:
 trigger:
   stage: deploy
   rules:
+    - when: never
     - if: $CI_MERGE_REQUEST_IID
   needs: [deploy]
   trigger:
@@ -194,13 +197,13 @@ check:
     - MERGE_REQUEST="${CI_MERGE_REQUEST_IID}";
 
     - MASTER_BRANCH=dunfell
-    - ./check_if_integration_branch_is_up_to_date.py
-        --gitlab-url=${CI_SERVER_URL}
-        --token=${GITBOT_TOKEN}
-        --manifest-project=${CI_PROJECT_ROOT_NAMESPACE}/yocto/manifest
-        --integration-base=${MASTER_BRANCH}
-        --project=${CI_PROJECT_PATH}
-        --merge-request=${CI_MERGE_REQUEST_IID}
+    # - ./check_if_integration_branch_is_up_to_date.py
+    #   --gitlab-url=${CI_SERVER_URL}
+    #   --token=${GITBOT_TOKEN}
+    #   --manifest-project=${CI_PROJECT_ROOT_NAMESPACE}/yocto/manifest
+    #   --integration-base=${MASTER_BRANCH}
+    #   --project=${CI_PROJECT_PATH}
+    #   --merge-request=${CI_MERGE_REQUEST_IID}
 
     # The check is done for both manifests in one job as the retrigger
     # looks for jobs named check, though there can only be one
@@ -212,3 +215,4 @@ check:
         --integration-base=master
         --project=${CI_PROJECT_PATH}
         --merge-request=${CI_MERGE_REQUEST_IID}
+        --verbose
diff --git a/common.yml b/common.yml
index 6bf9db6..f576e65 100644
--- a/common.yml
+++ b/common.yml
@@ -79,4 +79,5 @@ yamllint:
         --integration-base=${MASTER_BRANCH_MANIFEST}
         --project=${CI_PROJECT_PATH}
         --merge-request=${MERGE_REQUEST}
+        --verbose
         ${PARENT_MR}
diff --git a/foobar-manifest-integration.yml b/foobar-manifest-integration.yml
index 956cccc..3fee862 100644
--- a/foobar-manifest-integration.yml
+++ b/foobar-manifest-integration.yml
@@ -111,6 +111,7 @@ merge:
         --commit=${CI_COMMIT_SHA}
         --save-revision-to=manifest_revision
         --recipe-name=${BB_RECIPE_NAME}
+        --verbose
   artifacts:
     paths:
       - manifest_revision
diff --git a/merge_into_manifest.py b/merge_into_manifest.py
index 2ba9eb3..a55e4eb 100755
--- a/merge_into_manifest.py
+++ b/merge_into_manifest.py
@@ -2,6 +2,7 @@
 import common
 
 import argparse
+import logging
 import sys
 import time
 from gitlab import Gitlab
@@ -37,9 +38,10 @@ def merge_into_manifest(
         recipe_name=recipe_name,
         srcrev_file=srcrev_file,
     )
+    logging.debug(current_revisions)
     # This commit is contained there if current_revisions contains
     # it directly or any parrent of current_revisions is commit
-    for rev in current_revisions:
+    for rev in current_revisions.values():
         if common.is_commit_parent_of_project_commit(project, rev, commit):
             print(
                 "Commit {} is already merged into {}".format(
@@ -191,8 +193,16 @@ def main():
         dest="revision_file",
         required=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)
-- 
GitLab