Files
aws-doc-sdk-examples/.git-hooks/pre-commit
Corey Pyle bd4ab6a6a7 IAM Cleanup (#4646)
* consolidate iam client snippets
* move and clean up iam examples
* refactor basic scenario
* add integration tests
* update readme
* update linter
* apply editorial suggestions from code review
2023-04-07 11:07:21 -07:00

31 lines
672 B
Plaintext
Executable File

tag=[PRE-COMMIT]
function log {
echo "$tag $1"
}
# If any of the local directories contain staged changes, try
# and run pre-commit.sh.
for dir in $(ls -A) ; do
# Get a list of file names for changed files.
staged=$(git diff --cached --name-only -- "$dir")
if [ -n "$staged" ] ; then
log "The following files have staged changes in $dir:\n$staged"
if [ -x "${dir}/hook_scripts/pre-commit.sh" ] ; then
# Enter directory.
cd $dir
log "Working from $(pwd)..."
if ! "./hook_scripts/pre-commit.sh" ; then
log "$dir's pre-commit hook failed."
exit 1
fi
# Exit directory.
cd ..
fi
fi
done