show and fix 'style' complaints from shellcheck (#779)

pull/782/head
Josh Rabinowitz 2 years ago committed by GitHub
parent ef5a1e5235
commit ba1dc04f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -65,7 +65,7 @@ lint-shell:
docker run \
--volume="$${PWD}:/code" \
-w /code \
-e SHELLCHECK_OPTS='-s bash -S warning -a' \
-e SHELLCHECK_OPTS='-s bash -S style -a' \
--rm koalaman/shellcheck \
$$(find src .ci utils tests docs -type f \
-name '*.sh' -o -name '*.bash' -o -name '*.bats')

@ -29,7 +29,7 @@ function copy_to_posts {
current_date=$(date "+%Y-%m-%d")
# Creating command refernce:
for com in $MAN_LOCATION/git-secret-*.1.md; do
for com in "$MAN_LOCATION"/git-secret-*.1.md; do
local short_name
short_name=$(echo "$com" | sed -n "s|$MAN_LOCATION/\(.*\)\.1\.md|\1|p")
local command_header="---
@ -69,7 +69,7 @@ function copy_install_scripts {
function copy_version {
echo "$(./git-secret --version)" > docs/_includes/version.txt
./git-secret --version > docs/_includes/version.txt
}

@ -388,7 +388,7 @@ function _append_relative_root_path {
local subdir
subdir=$(git rev-parse --show-prefix) # get the subdir of repo, like "subdir/"
if [ ! -z "$subdir" ]; then
if [ -n "$subdir" ]; then
full_path="$(dirname "$full_path")/${subdir}/$(basename "$full_path")"
fi

@ -1,4 +1,6 @@
#!/usr/bin/env bats
# shellcheck disable=SC2030,SC2031
# above is to avoid shellcheck info warnings that we don't understand
load _test_base
@ -71,16 +73,17 @@ function teardown {
mkdir subdir
echo "content2" > subdir/new_filename.txt
cd subdir
run git secret add new_filename.txt
[ "$status" -eq 0 ]
run git secret hide
[ "$status" -eq 0 ]
( # start subshell for subdir tests
cd subdir
run git secret add new_filename.txt
[ "$status" -eq 0 ]
run git secret hide
[ "$status" -eq 0 ]
run git secret cat -d "$TEST_GPG_HOMEDIR" -p "$password" new_filename.txt
[ "$status" -eq 0 ]
run git secret cat -d "$TEST_GPG_HOMEDIR" -p "$password" new_filename.txt
[ "$status" -eq 0 ]
) # end subshell, cd back up
# clean up
cd ..
rm -rf subdir
}

@ -42,7 +42,7 @@ function teardown {
# File must be a binary:
local mime
mime="$(file --mime-type --mime-encoding "$new_file" | grep 'charset=binary')"
[ ! -z "$mime" ]
[ -n "$mime" ]
}
@ -61,7 +61,7 @@ function teardown {
# File must be a text:
local mime
mime="$(file --mime-type --mime-encoding "$new_file" | grep 'charset=us-ascii')"
[ ! -z "$mime" ]
[ -n "$mime" ]
}
@ -129,15 +129,17 @@ function teardown {
# Verify that the second file is there:
[ -f "$second_file" ]
# cd into the subdir
cd "$root_dir"
( # start subshell for following commands
# Now it should hide 2 files:
run git secret hide
[ "$status" -eq 0 ]
# cd into the subdir
cd "$root_dir"
# Now it should hide 2 files:
run git secret hide
[ "$status" -eq 0 ]
) # end subshell, return to ..
# cd back and clean up
cd ".."
# clean up
rm -rf "$root_dir"
}

@ -27,6 +27,8 @@ function teardown {
@test "run 'removeperson' with short name" {
local name
# don't complain about sed
# shellcheck disable=SC2001
name=$(echo "$TEST_DEFAULT_USER" | sed -e 's/@.*//')
# removeperson must use full email, not short name

@ -278,16 +278,17 @@ function teardown {
mkdir subdir
echo "content2" > subdir/new_filename.txt
cd subdir
run git secret add new_filename.txt
[ "$status" -eq 0 ]
run git secret hide
[ "$status" -eq 0 ]
run git secret reveal -d "$TEST_GPG_HOMEDIR" -p "$password" new_filename.txt
[ "$status" -eq 0 ]
( # start subshell for subdir tests
cd subdir
run git secret add new_filename.txt
[ "$status" -eq 0 ]
run git secret hide
[ "$status" -eq 0 ]
run git secret reveal -d "$TEST_GPG_HOMEDIR" -p "$password" new_filename.txt
[ "$status" -eq 0 ]
) # end subshell
# clean up
cd ..
rm -rf subdir
}

@ -199,6 +199,8 @@ function teardown {
install_fixture_key "$TEST_NOEMAIL_COMMENT_USER"
local name
# don't complain about sed
# shellcheck disable=SC2001
name=$(echo "$TEST_NOEMAIL_COMMENT_USER" | sed -e 's/@.*//')
# echo "$name" | sed "s/^/# '$BATS_TEST_DESCRIPTION' name is: /" >&3

Loading…
Cancel
Save