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

Cherry-picked from master with conflict resolution (lts-v2.8 branch already
contained adhoc changes to use itself as a reference for detecting which
commits belong to a current patchset, so this affectively syncs it with
master which uses more flexible and reusable scheme of getting it from
CI job params.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: Ic0fd0677978f226626d567108f17ccb864aa8095
diff --git a/script/static-checks/static-checks-coding-style-line-endings.sh b/script/static-checks/static-checks-coding-style-line-endings.sh
index bb0c4f4..785b054 100755
--- a/script/static-checks/static-checks-coding-style-line-endings.sh
+++ b/script/static-checks/static-checks-coding-style-line-endings.sh
@@ -5,7 +5,11 @@
 # SPDX-License-Identifier: BSD-3-Clause
 #
 
-TEST_CASE="Line endings not valid"
+this_dir="$(readlink -f "$(dirname "$0")")"
+. $this_dir/common.sh
+
+
+TEST_CASE="Line endings are valid"
 
 EXIT_VALUE=0
 
@@ -15,8 +19,11 @@
 
 if [[ "$2" == "patch" ]]; then
     cd "$1"
-    parent=$(git merge-base HEAD refs/remotes/origin/lts-v2.8 | head -1)
-    git diff ${parent}..HEAD --no-ext-diff --unified=0 --exit-code -a --no-prefix | awk '/^\+/ && /\r$/' &> "$LOG_FILE"
+    shopt -s globstar
+    parent=$(get_merge_base)
+    git diff $parent..HEAD --no-ext-diff --unified=0 --exit-code -a \
+      --no-prefix **/*.{S,c,h,i,dts,dtsi,rst,mk} Makefile | \
+      awk '/^\+/ && /\r$/' &> "$LOG_FILE"
 else
   # For all the source and doc files
   # We only return the files that contain CRLF