[mutter] ci: Use target branch from target project for code-style check



commit 5a25f2f62b34f50398a579fadfcbd163287993f4
Author: Robert Mader <robert mader posteo de>
Date:   Fri Aug 27 12:37:47 2021 +0200

    ci: Use target branch from target project for code-style check
    
    Merge requests from forked projects run pipelines in their context,
    not the target projects one. Thus we have to fetch the target
    branch from the target repository.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1977>

 .gitlab-ci.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 50400e7363..e251ca9184 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -151,8 +151,9 @@ check-code-style:
   script:
     - if [[ x"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "x" ]] ;
       then
-        git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME ;
-        export common_parent_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list 
--first-parent "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME") <(git rev-list --first-parent HEAD) | head -1) ;
+        git remote add target $CI_MERGE_REQUEST_PROJECT_URL.git ;
+        git fetch target $CI_MERGE_REQUEST_TARGET_BRANCH_NAME ;
+        export common_parent_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list 
--first-parent "target/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME") <(git rev-list --first-parent HEAD) | head -1) ;
         python3 -u ./check-style.py --dry-run --sha $common_parent_sha ;
       else
         echo "Not a merge request" ;


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