Skip to content

Commit

Permalink
Add shebang line to top of pre-commit hook so it can be used on Windo…
Browse files Browse the repository at this point in the history
…ws (awsdocs#6156)
  • Loading branch information
DennisTraub authored and max-webster committed Mar 15, 2024
1 parent d6fbe6b commit 9ee44b9
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions .git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
#!/bin/sh

tag=[PRE-COMMIT]
tag="[PRE-COMMIT]"

function log {
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")
for dir in * ; do
if [ -d "$dir" ]; then
# 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:"
log "$staged"
if [ -x "${dir}/hook_scripts/pre-commit.sh" ] ; then

# Enter directory.
(cd "$dir" || exit

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
log "Working from $(pwd)..."
if ! "./hook_scripts/pre-commit.sh" ; then
log "$dir's pre-commit hook failed."
exit 1
fi)
fi

# Exit directory.
cd ..
fi
fi
done

0 comments on commit 9ee44b9

Please sign in to comment.