Skip to content

Commit 3778698

Browse files
committed
Resolve lint warnings
1 parent d18cbee commit 3778698

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

tools/git/hooks/post-merge

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
#
2525
# This hook cannot does __not__ affect the outcome of `git merge` and is not executed if merge fails due to conflicts.
2626

27-
28-
# VARIABLES #
29-
30-
is_squash="$1"
27+
# shellcheck disable=SC2181
3128

3229

3330
# FUNCTIONS #
@@ -47,13 +44,16 @@ cleanup() {
4744

4845
# Checks if Node.js module dependencies have changed.
4946
check_node_deps() {
47+
local changed_files
48+
local package_json
49+
5050
echo 'Checking changed files...' >&2
5151

5252
# Get a list of changed files:
53-
local changed_files=$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)
53+
changed_files=$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)
5454

5555
# See if the root `package.json` is one of the files which changed:
56-
local package_json=$(echo "${changed_files}" | grep '^package\.json$')
56+
package_json=$(echo "${changed_files}" | grep '^package\.json$')
5757

5858
# If the root `package.json` changed, return a non-zero status...
5959
if [[ -n "${package_json}" ]]; then

tools/git/hooks/pre-commit

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#
2121
# This hook is called with no arguments.
2222

23+
# shellcheck disable=SC2181
24+
25+
2326
# VARIABLES #
2427

2528
# Determine root directory:
@@ -58,16 +61,19 @@ cleanup() {
5861

5962
# Checks for non-ASCII filenames (to ensure cross platform portability).
6063
check_filenames() {
61-
local commit=$(git rev-parse --verify HEAD)
64+
local num_files
6265
local against
66+
local commit
67+
68+
commit=$(git rev-parse --verify HEAD)
6369
if [[ -z "${commit}" ]]; then
6470
# This is the initial commit, so we diff against an empty tree object:
6571
against='4b825dc642cb6eb9a060e54bf8d69288fbee4904'
6672
else
6773
against='HEAD'
6874
fi
6975
# We exploit the fact that the printable range starts with the space character and ends with the tilde. Note that the use of brackets around a `tr` range is okay here, (for portability to Solaris 10's /usr/bin/tr, it's even required), since the square bracket bytes happen to fall in the designated range.
70-
local num_files=$(git diff --cached --name-only --diff-filter=A -z "${against}" | LC_ALL=C tr -d '[ -~]\0' | wc -c)
76+
num_files=$(git diff --cached --name-only --diff-filter=A -z "${against}" | LC_ALL=C tr -d '[ -~]\0' | wc -c)
7177

7278
if [[ "${num_files}" -ne 0 ]]; then
7379
echo 'Error: Attempting to add a non-ASCII filename. Non-ASCII filenames limit cross-platform portability. Please rename offending files before committing.' >&2

tools/git/hooks/pre-push

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
# <local ref> <local sha1> <remote ref> <remote sha1>
3232
# ```
3333

34+
# shellcheck disable=SC2181
35+
3436

3537
# VARIABLES #
3638

3739
remote="$1"
38-
url="$2"
3940

4041
# Determine the current branch:
41-
export GIT_CURRENT_BRANCH=$(git name-rev --name-only HEAD)
42+
GIT_CURRENT_BRANCH=$(git name-rev --name-only HEAD)
4243

4344
# Determine root directory:
4445
root=$(git rev-parse --show-toplevel)
@@ -67,7 +68,7 @@ has_commits() {
6768
if git branch -r | grep "${GIT_CURRENT_BRANCH}" > /dev/null; then
6869
echo 'Remote branch exists.' >&2
6970
echo 'Checking for commits to push...' >&2
70-
commits=$(git log "${remote}/${GIT_CURRENT_BRANCH}".."${GIT_CURRENT_BRANCH}" --oneline --)
71+
commits=$(git log "${remote}/${GIT_CURRENT_BRANCH}..${GIT_CURRENT_BRANCH}" --oneline --)
7172
else
7273
echo 'Remote branch does not exist.' >&2
7374
echo 'Checking for commits to push...' >&2
@@ -86,6 +87,7 @@ check_licenses() {
8687
echo 'Checking licenses...' >&2
8788
make check-licenses-production > /dev/null 2>&1
8889
if [[ "$?" -ne 0 ]]; then
90+
# shellcheck disable=SC2016
8991
echo 'Detected dependency licensing issues. Run `make check-licenses-production` to see failing dependency licenses.' >&2
9092
return 1
9193
fi
@@ -108,7 +110,7 @@ main() {
108110
fi
109111

110112
# Get the set of changed files (added and modified):
111-
changed_files=$(git diff --name-only --diff-filter AM "${remote}/${GIT_CURRENT_BRANCH}" | sed -e "s#^#${root}\/#")
113+
changed_files=$(git diff --name-only --diff-filter AM "${remote}/${GIT_CURRENT_BRANCH}" | sed -e "s#^#${root}\\/#")
112114

113115
# Run JavaScript example files:
114116
files=$(echo "${changed_files}" | grep '/examples/.*\.js$' | grep -v '/examples/fixtures/.*\.js$' | tr '\n' ' ')

0 commit comments

Comments
 (0)