Minor lint and pre-hook changes (#1349)

pull/1350/head
Gulshan Singh 3 years ago committed by GitHub
parent d0b14eea56
commit ac5a6ebe64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,14 +47,15 @@ else
black --check --diff ${LINT_FILES}
fi
flake8 --show-source ${LINT_FILES}
if [ -x "$(command -v shfmt)" ]; then
# Indents are four spaces, binary ops can start a line, and indent switch cases
shfmt -i 4 -bn -ci -d .
# Indents are four spaces, binary ops can start a line, indent switch cases,
# and allow spaces following a redirect
shfmt -i 4 -bn -ci -sr -d .
else
echo "shfmt not installed, skipping"
fi
# Checking minimum python version
vermin -q -t=3.6 --violations ./pwndbg/
flake8 --show-source ${LINT_FILES}

@ -32,7 +32,7 @@ p = pstats.Stats('${basedir}/stats')
p.strip_dirs().sort_stats('tottime').print_stats(20)
"
if command -v pyprof2calltree >/dev/null 2>&1 && command -v kcachegrind >/dev/null 2>&1; then
if command -v pyprof2calltree &> /dev/null && command -v kcachegrind &> /dev/null; then
pyprof2calltree -k -i "${basedir}/stats"
fi

@ -5,14 +5,35 @@ echo "# Install testing tools."
echo "# Only works with Ubuntu / APT."
echo "# --------------------------------------"
hook_script_name=".git/hooks/pre-push"
hook_script_path=".git/hooks/pre-push"
hook_script=$(
cat << 'EOF'
#!/bin/bash
diff_command="git diff --no-ext-diff --ignore-submodules"
old_diff=$($diff_command)
./lint.sh -f
exit_code=$?
new_diff=$($diff_command)
if [[ "$new_diff" != "$old_diff" ]]; then
echo "Files were modified by the linter, amend your commit and try again"
exit 1
fi
exit $exit_code
EOF
)
if [ -t 1 ]; then
echo "Install a git hook to automatically lint files before pushing? (y/N)"
read yn
if [[ "$yn" == [Yy]* ]]; then
echo "./lint.sh -f" >>$hook_script_name
echo "pre-push hook installed to $hook_script_name"
echo "$hook_script" > "$hook_script_path"
echo "pre-push hook installed to $hook_script_path"
fi
fi
@ -69,7 +90,7 @@ install_apt() {
tar -C /tmp -xJf /tmp/zig.tar.xz
mv /tmp/zig-linux-x86_64-* ${ZIGPATH} 2>/dev/null >/dev/null || true
mv /tmp/zig-linux-x86_64-* ${ZIGPATH} &> /dev/null || true
echo "Zig installed to ${ZIGPATH}"
}

Loading…
Cancel
Save