From 2873057592cc70933f5766551f1e086b553ccd26 Mon Sep 17 00:00:00 2001 From: xhe Date: Wed, 10 Aug 2022 13:46:47 +0800 Subject: [PATCH] *: do not rely on git to check file perm (#37008) --- Makefile | 2 +- tools/check/check-file-perm.sh | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a35dc9f3ca539..efc81a3886fbc 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ dev: checklist check explaintest gogenerate br_unit_test test_part_parser_dev ut # Install the check tools. check-setup:tools/bin/revive -check: check-parallel lint tidy testSuite errdoc bazel_golangcilinter bazel_all_build check-file-perm +check: check-file-perm check-parallel lint tidy testSuite errdoc bazel_golangcilinter bazel_all_build fmt: @echo "gofmt (simplify)" diff --git a/tools/check/check-file-perm.sh b/tools/check/check-file-perm.sh index 34ee3fed242ea..ae07ed6bdf47b 100755 --- a/tools/check/check-file-perm.sh +++ b/tools/check/check-file-perm.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # Copyright 2022 PingCAP, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +14,9 @@ # limitations under the License. # -find . \( -name "*.png" \ +FIND=$(which gfind || which find || echo "find") + +files="$($FIND . \( -name "*.png" \ -o -name "*.md" \ -o -name "*.toml" \ -o -name "*.yaml" \ @@ -25,14 +27,14 @@ find . \( -name "*.png" \ -o -name "*.png" \ -o -name "go.mod" \ -o -name "go.sum" \ -\) -exec chmod -x {} \; +\) -executable)" # no files should be changed -if [ -z "$(git status --untracked-files=no --porcelain)" ]; then +if [ -z "$files" ]; then exit 0 else echo "you may have files with wrong permission, for example an executable txt or png file" - git status + echo "$files" exit 1 fi