#!/bin/sh # This file is a part of Julia. License is MIT: https://julialang.org/license # Check for trailing white space in source files; # report an error if so # Files to check: set -f # disable glob expansion in this script global file_patterns := '' *.1 *.c *.cpp *.h *.jl *.lsp *.scm *.inc *.make *.mk *.md *.rst *.sh *.yml *Makefile '' # TODO: Look also for trailing empty lines, and missing '\n' after the last line if git --no-pager grep --color -n --full-name -e ' $' -- $file_patterns { echo "Error: trailing whitespace found in source file(s)" echo "" echo "This can often be fixed with:" echo " git rebase --whitespace=fix HEAD~1" echo "or" echo " git rebase --whitespace=fix master" echo "and then a forced push of the correct branch" exit 1 } (CommandList children: [ (C {(set)} {(-f)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:file_patterns) op: Equal rhs: { (SQ <"\n"> <"*.1\n"> <"*.c\n"> <"*.cpp\n"> <"*.h\n"> <"*.jl\n"> <"*.lsp\n"> <"*.scm\n"> <"*.inc\n"> <"*.make\n"> <"*.mk\n"> <"*.md\n"> <"*.rst\n"> <"*.sh\n"> <"*.yml\n"> <"*Makefile\n"> ) } spids: [24] ) ] spids: [24] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(git)} {(--no-pager)} {(grep)} {(--color)} {(-n)} {(--full-name)} {(-e)} {(SQ <" $">)} {(--)} {($ VSub_Name "$file_patterns")} ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Error: trailing whitespace found in source file(s)"))}) (C {(echo)} {(DQ )}) (C {(echo)} {(DQ ("This can often be fixed with:"))}) (C {(echo)} {(DQ (" git rebase --whitespace=fix HEAD~1"))}) (C {(echo)} {(DQ (or))}) (C {(echo)} {(DQ (" git rebase --whitespace=fix master"))}) (C {(echo)} {(DQ ("and then a forced push of the correct branch"))}) (C {(exit)} {(1)}) ] spids: [-1 73] ) ] spids: [-1 128] ) ] )