bash -n
is a basic but useful builtin syntax linter.
If you do not use the pre-commit
Python command & hook manager (check it out, it's great!), you can define a git
pre-commit hook "manually" by putting the following in a file at .git/hooks/pre-commit
:
#!/bin/sh
# Redirect output to stderr:
exec 1>&2
echo "Executing bash native syntax linter on all modified .sh files:"
if ! git diff --cached --name-only --diff-filter=AM HEAD | grep '.sh$' | xargs -n 1 bash -n
then
echo "Error : syntax issues were detected"
exit 1
fi
...in just one command :
cd path/to/your/git/repo
cat <<EOF >.git/hooks/pre-rebase
#!/bin/sh
echo -n \$'\x1b[36m' # start coloration (cyan)
curl -s https://raw.githubusercontent.com/jenkinsci/chucknorris-plugin/master/src/main/java/hudson/plugins/chucknorris/FactGenerator.java | sed '1,/FACTS = {/d;s/^ \+"//;s/"..\?$//;/^$/,$d …
First, lets mention Git Bash (aka msysgit) : the old version was a PITA to extend with additional packages (e.g. adding common C libs like libxml), and the new one (renamed Git for Windows), is based on MSYS2, but does not include a package manager.
Hence, we were left with …
I'd like to introduce you to an awesome git companion : pre-commit
hooks by Yelp.
Git hooks are scripts that git
executes before or after events such as: commit, push, and receive.
Git hooks are a built-in feature, but git
does not offer much support for them: if there is a …