Replies: 2 comments
-
I found this, maybe it will help: https://gist.github.com/vstakhov/ab6601054477e64fe50c |
Beta Was this translation helpful? Give feedback.
-
I checked the possibilities and I don't feel like it's a job for a framework to check the filenames as it's too late to check when the framework starts to do anything. I can easily create a new branch, add a file with trailing space in the filename, push, and no check is performed (failed test on the CI is nice, but the damage is done already). I can suggest following pre-commit hook, or better the one Tomas suggested. click to show#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# Redirect output to stderr.
exec 1>&2
if test $(git diff --cached --name-only --diff-filter=A -z $against | sed '/^[+-]/d' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a file name with leading/trailing whitespace in filename.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against -- but this has to be done individually for each developer. Another option is to set the server hook on the git server. |
Beta Was this translation helpful? Give feedback.
-
I have one idea, which can helps me or a team.
If somebody push to repo file named with white space on its end, another person with Windows will not be able use git after checkout on branch with this file.
Its not the problem of SSFW, i know, but if it happen, people will spend lot of hours searching for a problem with file and it will end with "only way is to clone and buildproject again".
Also white space on the end of file name is not visible for people, so no one will notice that and i will be so happy, that this type of test could help others to crecognize problem early on CI or localhost before they will spread problem to others with Windows.
Beta Was this translation helpful? Give feedback.
All reactions