From 05cb63dd7088b6da1bb820333778758346ce1559 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastian=20K=C3=B6cher?= <bkchr@users.noreply.github.com>
Date: Thu, 7 May 2020 12:50:25 +0200
Subject: [PATCH] Merge Substrate master before checking Polkadot companion
 (#5916)

* Merge Substrate master before checking Polkadot companion

* Also merge polkadot/master into the companion pr branch

* Set email and user name
---
 .../gitlab/check_polkadot_companion_build.sh          | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/substrate/.maintain/gitlab/check_polkadot_companion_build.sh b/substrate/.maintain/gitlab/check_polkadot_companion_build.sh
index eb4c6440f46..c2ecf8cb6a0 100755
--- a/substrate/.maintain/gitlab/check_polkadot_companion_build.sh
+++ b/substrate/.maintain/gitlab/check_polkadot_companion_build.sh
@@ -39,15 +39,22 @@ substrate's branch. if it can't find anything, it will uses master instead
 
 EOT
 
+# Set the user name and email to make merging work
+git config --global user.name 'CI system'
+git config --global user.email '<>'
 
 SUBSTRATE_PATH=$(pwd)
 
+# Merge master into our branch before building Polkadot to make sure we don't miss
+# any commits that are required by Polkadot.
+git merge origin/master
+
 # Clone the current Polkadot master branch into ./polkadot.
 git clone --depth 1 https://github.com/paritytech/polkadot.git
 
 cd polkadot
 
-# either it's a pull request then check for a companion otherwise use 
+# either it's a pull request then check for a companion otherwise use
 # polkadot:master
 if expr match "${CI_COMMIT_REF_NAME}" '^[0-9]\+$' >/dev/null
 then
@@ -78,12 +85,14 @@ then
     boldprint "companion pr specified/detected: #${pr_companion}"
     git fetch --depth 1 origin refs/pull/${pr_companion}/head:pr/${pr_companion}
     git checkout pr/${pr_companion}
+    git merge origin/master
   else
     pr_ref="$(grep -Po '"ref"\s*:\s*"\K(?!master)[^"]*' "${pr_data_file}")"
     if git fetch --depth 1 origin "$pr_ref":branch/"$pr_ref" 2>/dev/null
     then
       boldprint "companion branch detected: $pr_ref"
       git checkout branch/"$pr_ref"
+      git merge origin/master
     else
       boldprint "no companion branch found - building polkadot:master"
     fi
-- 
GitLab