util/lint: Unify checks for git worktree
Linters try to determine whether they are running in a git worktree so that `git grep` can be used instead of `grep`. These checks are done in different not truly correct ways and thus the linters don't use `git grep` when running from a worktree subdirectory, e.g. in a git subtree environment. Unify checks using `git rev-parse --is-inside-work-tree`. Change-Id: I3f54afc99ad0f0e3052cffdd32bdd9649cf3d720 Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot@gmail.com> Reviewed-on: https://review.coreboot.org/23297 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
583e0522f1
commit
73f19dca38
|
@ -23,7 +23,9 @@ fi
|
|||
|
||||
# If coreboot is in a git repo, use git grep to check as it will ignore any
|
||||
# files in the tree that aren't checked into git
|
||||
if [ -n "$(command -v git)" ] && [ -e ".git" ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
env perl util/lint/kconfig_lint
|
||||
else
|
||||
env perl util/lint/kconfig_lint --no_git_grep
|
||||
|
|
|
@ -21,7 +21,9 @@ EXCLUDED_DIRS='^src/vendorcode\|^util/romcc\|cbfstool/lzma\|cbfstool/lz4'
|
|||
INCLUDED_FILES='\.[ch]:'
|
||||
|
||||
# Use git grep if the code is in a git repo, otherwise use grep.
|
||||
if [ -n "$(command -v git)" ] && [ -d .git ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
GREP_FILES="git grep -n"
|
||||
else
|
||||
GREP_FILES="grep -rn"
|
||||
|
|
|
@ -22,7 +22,9 @@ EXCLUDED_FILES='to-wiki/towiki\.sh$\|vga/vga_font\|video/font\|PDCurses.*x11'
|
|||
EXCLUDED_PHRASES='Copyright\|Ported to\|Intel®\|°C\|°F\|Athlon™\|Copyright.*©\|A-Za-zÀ-ÿ'
|
||||
|
||||
# Use git ls-files if the code is in a git repo, otherwise use find.
|
||||
if [ -n "$(command -v git)" ] && [ -d .git ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
FIND_FILES="git ls-files"
|
||||
else
|
||||
FIND_FILES="find . "
|
||||
|
|
|
@ -20,7 +20,9 @@ EXCLUDED_DIRS='src/vendorcode/\|util/romcc/\|cbfstool/lzma/\|cbfstool/lz4/\|Docu
|
|||
EXCLUDED_FILES='\.jpg$\|\.cksum$\|\.bin$\|\.hex$\|\.ico$\|\.o$\|\.bz2$\|\.xz$\|^.tmpconfig\|\.pyc$\|_shipped$\|sha256$\|\.png$\|\.patch$'
|
||||
|
||||
# Use git ls-files if the code is in a git repo, otherwise use find.
|
||||
if [ -n "$(command -v git)" ] && [ -d .git ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
FIND_FILES="git ls-files"
|
||||
else
|
||||
FIND_FILES="find . "
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
# DESCR: Check for a signed-off-by line on the latest git commit
|
||||
|
||||
# This test is mainly for the jenkins server
|
||||
if [ -n "$(command -v git)" ] && [ -d .git ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
if [ -z "$(git log -n 1 | grep '[[:space:]]\+Signed-off-by: ')" ]; then
|
||||
echo "No Signed-off-by line in commit message"
|
||||
fi
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
LC_ALL=C export LC_ALL
|
||||
|
||||
# Use git ls-files if the code is in a git repo, otherwise use find.
|
||||
if [ -n "$(command -v git)" ] && [ -d .git ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
FIND_FILES="git ls-files"
|
||||
else
|
||||
FIND_FILES="find src"
|
||||
|
|
|
@ -23,7 +23,9 @@ fi
|
|||
|
||||
# If coreboot is in a git repo, use git grep to check as it will ignore any
|
||||
# files in the tree that aren't checked into git
|
||||
if [ -n "$(command -v git)" ] && [ -e ".git" ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
env perl util/lint/kconfig_lint --warnings_off 2>&1
|
||||
else
|
||||
env perl util/lint/kconfig_lint --no_git_grep --warnings_off 2>&1
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
|
||||
LC_ALL=C export LC_ALL
|
||||
|
||||
if [ -n "$(command -v git)" ] && [ -e ".git" ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
if [ -n "$(git ls-files site-local/*)" ]; then
|
||||
echo "Error: site-local must be kept separate from the coreboot repository."
|
||||
fi
|
||||
|
|
|
@ -19,7 +19,9 @@ LC_ALL=C export LC_ALL
|
|||
SYMBOLS='CONFIG_ARCH_\|CONFIG_MAINBOARD_HAS_'
|
||||
|
||||
# Use git grep if the code is in a git repo, otherwise use grep.
|
||||
if [ -n "$(command -v git)" ] && [ -d .git ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
GREP="git grep -l"
|
||||
else
|
||||
GREP="grep -rl"
|
||||
|
|
|
@ -19,7 +19,9 @@ LC_ALL=C export LC_ALL
|
|||
EXCLUDED_DIRS='^3rdparty\|^site-local'
|
||||
|
||||
# If the code is in a git repo, only print files that are checked in
|
||||
if [ -n "$(command -v git)" ] && [ -d .git ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
git ls-tree -r HEAD | \
|
||||
grep ^120000 | \
|
||||
cut -f2 | \
|
||||
|
|
|
@ -23,7 +23,9 @@ EXCLUDED_FILES='src/include/kconfig.h'
|
|||
HEADER_FILES="k*config"
|
||||
|
||||
# Use git grep if the code is in a git repo, otherwise use grep.
|
||||
if [ -n "$(command -v git)" ] && [ -d .git ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
GREP_FILES="git grep -n"
|
||||
else
|
||||
GREP_FILES="grep -rn"
|
||||
|
|
|
@ -19,7 +19,9 @@ LC_ALL=C export LC_ALL
|
|||
EXCLUDE='^3rdparty/\|util/crossgcc/xgcc\|Binary file\|coreboot\|COREBOOT\|CorebootPayload\|CorebootModule\|minnowboard.org/Coreboot\|.*\.patch$\|CorebootBdsLib\|^payloads/external'
|
||||
|
||||
# Use git grep if the code is in a git repo, otherwise use grep.
|
||||
if [ -n "$(command -v git)" ] && [ -d .git ]; then
|
||||
if [ -n "$(command -v git)" ] && \
|
||||
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
|
||||
then
|
||||
GREP_FILES="git grep -in"
|
||||
|
||||
# Check last commit message
|
||||
|
|
Loading…
Reference in New Issue