Skip to content

Commit

Permalink
*: do not rely on git to check file perm (#37008)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhebox authored Aug 10, 2022
1 parent f3eb59c commit 2873057
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
12 changes: 7 additions & 5 deletions tools/check/check-file-perm.sh
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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" \
Expand All @@ -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

0 comments on commit 2873057

Please sign in to comment.