unbrake-api/scripts/run_container_hook
#!/bin/sh
#===================================================
# It's a reduced run_container_hook from Frontend.
# I made this way because each environment will be
# runned on a different container, so share code
# is hard.
#===================================================
hookName="$1"
add_file(){
file="$1"
if [ -e "$file" ]; then
git add "$file"
elif [ "$hookName" = "pre-commit" ] || [ "$hookName" = "pre-push" ]; then
echo -e "\033[0;33mINFO:\033[0m file '$file' will not be checked because it's not allowed to be in docker."
fi
}
convert_git_workspace() {
(cd /app && git diff --name-only --cached | grep unbrake-api | sed s@unbrake-api/@@) > /tmp/unbrake_staged \
&& git init &>/dev/null \
&& [ -s /tmp/unbrake_staged ] \
&& for file in $(cat /tmp/unbrake_staged); do add_file "$file"; done \
&& rm -rf /tmp/unbrake_staged
}
convert_git_workspace
echo -e "\n=========================================================================="
echo "Checking API..."
echo -e "==========================================================================\n"
"/app/api/hooks/$hookName" "${@:2}"