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 \ docker run \
--volume="$${PWD}:/code" \ --volume="$${PWD}:/code" \
-w /code \ -w /code \
-e SHELLCHECK_OPTS='-s bash -S warning -a' \ -e SHELLCHECK_OPTS='-s bash -S style -a' \
--rm koalaman/shellcheck \ --rm koalaman/shellcheck \
$$(find src .ci utils tests docs -type f \ $$(find src .ci utils tests docs -type f \
-name '*.sh' -o -name '*.bash' -o -name '*.bats') -name '*.sh' -o -name '*.bash' -o -name '*.bats')

@ -29,7 +29,7 @@ function copy_to_posts {
current_date=$(date "+%Y-%m-%d") current_date=$(date "+%Y-%m-%d")
# Creating command refernce: # 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 local short_name
short_name=$(echo "$com" | sed -n "s|$MAN_LOCATION/\(.*\)\.1\.md|\1|p") short_name=$(echo "$com" | sed -n "s|$MAN_LOCATION/\(.*\)\.1\.md|\1|p")
local command_header="--- local command_header="---
@ -69,7 +69,7 @@ function copy_install_scripts {
function copy_version { 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 local subdir
subdir=$(git rev-parse --show-prefix) # get the subdir of repo, like "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")" full_path="$(dirname "$full_path")/${subdir}/$(basename "$full_path")"
fi fi

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

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

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

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

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

Loading…
Cancel
Save