diff options
author | Alex Thiessen <alex.thiessen.de+coreboot@gmail.com> | 2018-01-16 23:05:48 +0000 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2018-01-23 05:42:51 +0000 |
commit | 73f19dca386d775a880bdc945efaa6b9c77d9e94 (patch) | |
tree | b7814be8453de7044ad8078fc048aae2514ec5d4 /util/lint | |
parent | 583e0522f14fde040f48d2444099e4dededfa185 (diff) |
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>
Diffstat (limited to 'util/lint')
-rwxr-xr-x | util/lint/lint-008-kconfig | 4 | ||||
-rwxr-xr-x | util/lint/lint-014-qualified-types | 4 | ||||
-rwxr-xr-x | util/lint/lint-016-non-ascii | 4 | ||||
-rwxr-xr-x | util/lint/lint-extended-015-final-newlines | 4 | ||||
-rwxr-xr-x | util/lint/lint-extended-020-signed-off-by | 4 | ||||
-rwxr-xr-x | util/lint/lint-stable-004-style-labels | 4 | ||||
-rwxr-xr-x | util/lint/lint-stable-008-kconfig | 4 | ||||
-rwxr-xr-x | util/lint/lint-stable-013-site-local | 4 | ||||
-rwxr-xr-x | util/lint/lint-stable-017-configs | 4 | ||||
-rwxr-xr-x | util/lint/lint-stable-018-symlinks | 4 | ||||
-rwxr-xr-x | util/lint/lint-stable-019-header-files | 4 | ||||
-rwxr-xr-x | util/lint/lint-stable-021-coreboot-lowercase | 4 |
12 files changed, 36 insertions, 12 deletions
diff --git a/util/lint/lint-008-kconfig b/util/lint/lint-008-kconfig index d3da17ea5d..8a0042d2da 100755 --- a/util/lint/lint-008-kconfig +++ b/util/lint/lint-008-kconfig @@ -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 diff --git a/util/lint/lint-014-qualified-types b/util/lint/lint-014-qualified-types index 58b48b705e..98679ea55e 100755 --- a/util/lint/lint-014-qualified-types +++ b/util/lint/lint-014-qualified-types @@ -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" diff --git a/util/lint/lint-016-non-ascii b/util/lint/lint-016-non-ascii index 881eeba69e..beffd83dd6 100755 --- a/util/lint/lint-016-non-ascii +++ b/util/lint/lint-016-non-ascii @@ -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 . " diff --git a/util/lint/lint-extended-015-final-newlines b/util/lint/lint-extended-015-final-newlines index bfaa817e1f..1315dbdee5 100755 --- a/util/lint/lint-extended-015-final-newlines +++ b/util/lint/lint-extended-015-final-newlines @@ -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 . " diff --git a/util/lint/lint-extended-020-signed-off-by b/util/lint/lint-extended-020-signed-off-by index 40b6e9eb42..065b286d34 100755 --- a/util/lint/lint-extended-020-signed-off-by +++ b/util/lint/lint-extended-020-signed-off-by @@ -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 diff --git a/util/lint/lint-stable-004-style-labels b/util/lint/lint-stable-004-style-labels index 7b68b4ad63..698b22df78 100755 --- a/util/lint/lint-stable-004-style-labels +++ b/util/lint/lint-stable-004-style-labels @@ -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" diff --git a/util/lint/lint-stable-008-kconfig b/util/lint/lint-stable-008-kconfig index 06e41b8570..25d04b6c7c 100755 --- a/util/lint/lint-stable-008-kconfig +++ b/util/lint/lint-stable-008-kconfig @@ -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 diff --git a/util/lint/lint-stable-013-site-local b/util/lint/lint-stable-013-site-local index 43c4542a04..d701ee07b3 100755 --- a/util/lint/lint-stable-013-site-local +++ b/util/lint/lint-stable-013-site-local @@ -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 diff --git a/util/lint/lint-stable-017-configs b/util/lint/lint-stable-017-configs index 782c183c24..6d7393db81 100755 --- a/util/lint/lint-stable-017-configs +++ b/util/lint/lint-stable-017-configs @@ -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" diff --git a/util/lint/lint-stable-018-symlinks b/util/lint/lint-stable-018-symlinks index 833507c294..6f58e7ddd0 100755 --- a/util/lint/lint-stable-018-symlinks +++ b/util/lint/lint-stable-018-symlinks @@ -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 | \ diff --git a/util/lint/lint-stable-019-header-files b/util/lint/lint-stable-019-header-files index 1ce6cc525f..11bc432679 100755 --- a/util/lint/lint-stable-019-header-files +++ b/util/lint/lint-stable-019-header-files @@ -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" diff --git a/util/lint/lint-stable-021-coreboot-lowercase b/util/lint/lint-stable-021-coreboot-lowercase index 82e2dd4160..a71d2047f3 100755 --- a/util/lint/lint-stable-021-coreboot-lowercase +++ b/util/lint/lint-stable-021-coreboot-lowercase @@ -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 |