git-lfs/script/fmt
Sebastian Schuberth 7261b7140f Do not run gofmt in the src directory
All the src contains is a symbolic link to the root, causing gofmt to
indefinitely recurse until it errors out. On Windows, this causes an error
message like

    GetFileAttributesEx
    src\github.com\github\git-lfs\src\github.com\github\git-lfs\src\github.com\github\git-lfs\src\github.com\github\git-lfs\src\github.com\github\git-lfs\.git\objects\pack\pack-2fc21819ce9855ebf1a1f3ac77cf464c8a4e6e42.idx:
    The system cannot find the path specified.
2016-09-06 11:15:05 +02:00

22 lines
384 B
Bash
Executable File

#!/usr/bin/env bash
formatter=gofmt
hash goimports 2>/dev/null && {
formatter=goimports
}
# don't run gofmt in these directories
ignored=(/bin/ /docs/ /log/ /man/ /tmp/ /vendor/ /rpm/ /docker/ /debian/ /src/)
for i in */ ; do
if [[ ! ${ignored[*]} =~ "/$i" ]]; then
$formatter -w -l "$@" "${i%?}"
fi
done
msg=`script/lint`
if [ $? -ne 0 ];
then
echo "$msg"
exit 1
fi