File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -279,6 +279,19 @@ check_gitattributes() {
279279# Check for trailing newline and whitespace-only lines in all files
280280check_file_formatting () {
281281 local file
282+
283+ # Check if git command exists
284+ if ! command -v git > /dev/null 2>&1 ; then
285+ info_messages+=(" git command not found, skipping file formatting checks" )
286+ return
287+ fi
288+
289+ # Check for untracked files
290+ if [[ -n " $( git ls-files --others --exclude-standard 2> /dev/null) " ]]; then
291+ actions+=(" Untracked files exist. Please stage or remove them before running file formatting checks." )
292+ return
293+ fi
294+
282295 # Get all tracked files from git, excluding binary files and specific patterns
283296 while IFS= read -r -d ' ' file; do
284297 # Skip binary files and images
@@ -295,7 +308,7 @@ check_file_formatting() {
295308 if grep -qn ' ^[[:space:]]\+$' " $file " 2> /dev/null; then
296309 actions+=(" $file contains lines with only spaces/tabs, remove trailing whitespace" )
297310 fi
298- done < <( git ls-files -z 2> /dev/null | grep -zv ' ^tests/testdata/' || find . -type f -not -path ' ./.git/* ' -not -path ' ./tests/testdata/* ' -print0 2> /dev/null )
311+ done < <( git ls-files -z 2> /dev/null | grep -zv ' ^tests/testdata/' )
299312}
300313
301314# Main function
You can’t perform that action at this time.
0 commit comments