forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shebang line to top of pre-commit hook so it can be used on Windo…
…ws (awsdocs#6156)
- Loading branch information
1 parent
d6fbe6b
commit 9ee44b9
Showing
1 changed file
with
19 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |