1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00
cdt/releng/scripts/do_remove_trailing_whitespace.sh
Torbjörn Svensson e632011f2c Bug 568728: Drop execute permission on files
Add enforecment script that verifies that only specified file types are
allowed to be mared as executable.

Change-Id: I4b40e3a46b03bfc78a9dcd52e8bf29cb079b7f3b
Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
2020-11-18 17:38:22 +01:00

25 lines
1,008 B
Bash
Executable file

#!/bin/bash
###############################################################################
# Copyright (c) 2018, 2020 Kichwa Coders Ltd and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
###############################################################################
set -e
##
# Remove trailing whitespace.
# The .gitattributes is used as a filter to identify files to check. Patterns
# with this "# check trailing whitespace" on the line before are checked
# (lines in .gitattributes starting with '#' are ignored).
##
awk '/# remove trailing whitespace/{do getline; while ($0 ~ /^#/); print $1}' .gitattributes |
while read i ; do
echo "Removing trailing whitespace on $i files"
git ls-files -z -- "$i" | xargs --null --no-run-if-empty sed -i 's/[ \t]*$//'
done