diff options
author | Evan Read <eread@gitlab.com> | 2022-01-17 04:10:32 +0300 |
---|---|---|
committer | Russell Dickenson <rdickenson@gitlab.com> | 2022-01-17 04:10:32 +0300 |
commit | a7d7f5ef5e320b08dfe2c17a969d93653f2774b5 (patch) | |
tree | 7e43296fe0947f298911a340ebb4b8f31b8eb827 /tasks | |
parent | 05218c6687877105dcdd1e147a7b601f6e176ce4 (diff) |
Return error code if unlinked files are found
Diffstat (limited to 'tasks')
-rwxr-xr-x | tasks/unlinked-images.sh | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tasks/unlinked-images.sh b/tasks/unlinked-images.sh index d7c9f704..a210cc48 100755 --- a/tasks/unlinked-images.sh +++ b/tasks/unlinked-images.sh @@ -1,3 +1,20 @@ -for FILE in $(git ls-files ./$1/*.png ./$1/**/*.gif ./$1/**/*.jpg); do - git grep $(basename "$FILE") > /dev/null || echo "Unlinked file: $FILE" +#!/bin/bash + +unlinked_files=0 + +if [[ -z "$1" ]]; then + echo "ERROR: No search path supplied." + exit 1 +fi + +for FILE in $(git ls-files ./"$1"/*.png ./"$1"/**/*.gif ./"$1"/**/*.jpg); do + if ! git grep "$(basename "$FILE")" > /dev/null; then echo "Unlinked file: $FILE"; unlinked_files+=1; fi done + +if [[ $unlinked_files -gt 0 ]]; then + echo "ERROR: Unlinked files found." + exit 1 +else + echo "INFO: No unlinked files found." + exit 0 +fi |