-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a script to check for line endings (valid UNIX ending)
-Created a bash script using grep to check for carriage return at line endings. -Works for modified and new files only (if choosen) -Modified build_and_run.sh to include the new check.sh and run it.
- Loading branch information
1 parent
96e6d2a
commit db97416
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (C) 2015 Kushal Singh <[email protected]> | ||
# | ||
# This file is subject to the terms and conditions of the GNU Lesser | ||
# General Public License v2.1. See the file LICENSE in the top level | ||
# directory for more details. | ||
# | ||
|
||
BRANCH=${1} | ||
FILEREGEX='\.([sScHh]|cpp)$' | ||
ENDREGEX='^M$' | ||
|
||
# If no branch but an option is given, unset BRANCH. | ||
# Otherwise, consume this parameter. | ||
if echo "${BRANCH}" | grep -q '^-'; then | ||
BRANCH="" | ||
else | ||
if [ -n "${BRANCH}" ]; then | ||
shift 1 | ||
fi | ||
fi | ||
|
||
# If the --diff-filter option is given, consume this parameter. | ||
# Set the default DIFFFILTER option otherwise. | ||
DIFFFILTER="${1}" | ||
if echo "${DIFFFILTER}" | grep -q '^--diff-filter='; then | ||
shift 1 | ||
else | ||
DIFFFILTER="--diff-filter=ACMR" | ||
fi | ||
|
||
# select either all or only touched-in-branch files, filter through FILEREGEX | ||
if [ -z "${BRANCH}" ]; then | ||
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})" | ||
else | ||
FILES="$(git diff ${DIFFFILTER} --name-only ${BRANCH} | grep -E ${FILEREGEX})" | ||
fi | ||
|
||
if [ -z "${FILES}" ]; then | ||
exit | ||
fi | ||
|
||
grep -E -R -l ${ENDREGEX} ${FILES} > /dev/null | ||
|
||
if [ $? -eq 0 ] | ||
then | ||
echo "ERROR: carriage return error found" | ||
exit 1 | ||
else | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters