static-checks: Use proper ref branch when collecting commits to test

Use the actual branch specified in the CI run, instead of hardcoded
master/integration.

Addresses https://linaro.atlassian.net/browse/TFC-636

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: Ic0fd0677978f226626d567108f17ccb864aa8095
diff --git a/script/static-checks/static-checks-include-order.sh b/script/static-checks/static-checks-include-order.sh
index 52e783c..364929c 100755
--- a/script/static-checks/static-checks-include-order.sh
+++ b/script/static-checks/static-checks-include-order.sh
@@ -7,13 +7,17 @@
 
 # unittest-include-order.sh <path-to-root-folder> [patch]
 
+this_dir="$(readlink -f "$(dirname "$0")")"
+. $this_dir/common.sh
+
+
 LOG_FILE=$(mktemp -t include-order-check.XXXX)
 
 if [[ "$2" == "patch" ]]; then
-  echo "# Check order of includes on the last patch"
-  TEST_CASE="Order of includes on the last patch(es)"
+  TEST_CASE="Order of includes on the patch series"
+  echo "# $TEST_CASE"
   "$CI_ROOT/script/static-checks/check-include-order.py" --tree "$1" \
-      --patch --from-ref origin/master \
+      --patch --from-ref $(get_merge_base) \
       &> "$LOG_FILE"
 else
   echo "# Check order of includes of the entire source tree"