File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -114,3 +114,27 @@ jobs:
114114 exit "$rc"
115115 ' sh < "$files_list"
116116
117+ - name : Check for trailing whitespace in .sh files (pull_request)
118+ if : github.event_name == 'pull_request'
119+ env :
120+ BASE_BRANCH : ${{ github.base_ref }}
121+ run : |
122+ set -eu
123+
124+ if [ -z "$BASE_BRANCH" ]; then
125+ echo "BASE_BRANCH is empty"
126+ exit 1
127+ fi
128+
129+ if ! git check-ref-format --branch "$BASE_BRANCH" >/dev/null 2>&1; then
130+ echo "Invalid base branch name: $BASE_BRANCH"
131+ exit 1
132+ fi
133+
134+ git fetch --no-tags origin "+refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH}"
135+
136+ MERGE_BASE="$(git merge-base HEAD "refs/remotes/origin/${BASE_BRANCH}")"
137+
138+ git diff --check "${MERGE_BASE}"...HEAD \
139+ && echo "No trailing whitespace found." \
140+ || { echo "ERROR: Trailing whitespace or space/tab conflict found!"; exit 1; }
You can’t perform that action at this time.
0 commit comments