From 48380672f2b7b46ad86a8157204bf4e02742c1f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dylan=20A=C3=AFssi?= <dylan.aissi@collabora.com>
Date: Wed, 18 Sep 2024 17:14:29 +0200
Subject: [PATCH] import-debian-package: don't trigger pipeline on downstream,
 instead create a merge request
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Actually pipelines on downstreams fail at this step because these branches
are missing the debian/apertis/copyright file. Instead we create a merge request,
thus the missing file will be generated with the job scan-licenses.

Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
---
 tools/import-debian-package | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/import-debian-package b/tools/import-debian-package
index b53baba..eb0d0a2 100755
--- a/tools/import-debian-package
+++ b/tools/import-debian-package
@@ -220,7 +220,9 @@ def import_debian_dsc(args, dsc_file: Path, upstream: str, downstream: str, vers
             git.tag('-d', epochless_tag)
             commit = parse_ref(debian_tag)
         force_branch(downstream, commit)
-        git.checkout(f'{downstream}')
+        proposed_branch = f'proposed-package/{downstream}'
+        force_branch(proposed_branch, commit)
+        git.checkout(f'{proposed_branch}')
         logging.info('Adding Apertis delta')
         f_compo = Path('debian/apertis/component')
         f_compo.parent.mkdir(exist_ok=True)
@@ -401,9 +403,10 @@ def do_import(args):
         logging.info('Applying Gitlab rules')
         apply_gitlab_rulez(args.gitlab_instance, args.gitlab_server_url, args.gitlab_api_token, args.package)
 
-        logging.info('Triggering CI pipelines on downstream branches')
-        for branch in [downstream] + args.downstreams:
-            project.pipelines.create({'ref': branch})
+        logging.info('Creating merge request')
+        mr = project.mergerequests.create({'source_branch': f'proposed-package/{downstream}',
+                                           'target_branch': downstream,
+                                           'title': f'Initial import of {package}'})
 
 def parse_abspath(path):
     return argparse.FileType('r')(os.path.abspath(path))
-- 
GitLab