From 5bb84a04cd6de815350f7dbcf59dd04c2b94a6f7 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     | 17 ++++++++++-------
 common.py          |  2 +-
 merge_gitlab_ci.py |  6 ++++--
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c81a929d..9723e4b6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -30,27 +30,30 @@ workflow:
 # ---------------------------------------------------------------------------------------
 # Stage: analyze
 # ---------------------------------------------------------------------------------------
-pylint:
+.analyze:
   stage: analyze
+  rules:
+    - if: $CI_COMMIT_BRANCH == "master"
+      when: never
   timeout: 2m
+
+pylint:
+  extends: .analyze
   script:
     - pylint --rcfile=pylintrc *.py
 
 black:
-  stage: analyze
-  timeout: 2m
+  extends: .analyze
   script:
     - black --diff --check *.py
 
 executable:
-  stage: analyze
-  timeout: 2m
+  extends: .analyze
   script:
     - (! find ! -executable -name "*.py" -exec echo "not executable:"" {}" \; | grep .)
 
 yamllint:
-  stage: analyze
-  timeout: 2m
+  extends: .analyze
   script:
     - yamllint -c .yamllint.yml *.yml .*.yml
 
diff --git a/common.py b/common.py
index 9963bf7d..b147aae8 100755
--- a/common.py
+++ b/common.py
@@ -280,7 +280,7 @@ def is_commit_parent_of_project_commit(project: Project, project_commit, commit)
             ) from e
 
         # The integration branch is up to date if its parent is the integration base
-        logging.debug(parent.id)
+        logging.debug("Compare '%s' and '%s'",parent.id, commit)
         if parent.id == commit:
             return True
         if len(parent.parent_ids) == 0:
diff --git a/merge_gitlab_ci.py b/merge_gitlab_ci.py
index 04af7728..eeaa3a7c 100755
--- a/merge_gitlab_ci.py
+++ b/merge_gitlab_ci.py
@@ -132,7 +132,9 @@ def main():
 
     gitlab = Gitlab(args.gitlab_url, private_token=args.token)
 
-    for p in args.projects + [args.project]:
+    # Start with the manifest here, so the subproject
+    # can see that they are already integrated
+    for p in [args.project] + args.projects:
         project = common.get_project(gitlab, p)
         branch = args.branch
 
@@ -177,7 +179,7 @@ def main():
                 )
             )
             found = False
-            for p2 in args.projects + [args.project]:
+            for p2 in [args.project] + args.projects:
                 if p2 == p:
                     found = True
                     continue
-- 
GitLab