telegram-bot-bash/dev/git-add.sh
Kay Marquardt (Gnadelwartz) 9ef8778f85 dev/: fix missing ${xxx}
2021-01-05 11:40:28 +01:00

38 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# file: git-add.sh
#
# works together with git pre-push.sh and ADD all changed files since last push
#### $$VERSION$$ v1.25-dev-6-g641727d
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
if [ "${GIT_DIR}" != "" ] ; then
cd "${GIT_DIR}/.." || exit 1
else
printf "Sorry, no git repository %s\n" "$(pwd)" && exit 1
fi
[ ! -f .git/.lastcommit ] && printf "No previous commit or hooks not installed, use \"git add\" instead ... Abort\n" && exit
set +f
FILES="$(find ./* -newer .git/.lastcommit| grep -v -e 'DIST\/' -e 'STANDALONE\/' -e 'JSON.sh')"
set -f
# FILES="$(find ./* -newer .git/.lastpush)"
[ "${FILES}" = "" ] && printf "Nothing changed since last commit ...\n" && exit
# run pre_commit on files
dev/hooks/pre-commit.sh
printf "Add files to repo: "
# shellcheck disable=SC2086
for file in ${FILES}
do
[ -d "${file}" ] && continue
printf "%s" "${file} "
git add "${file}"
done
printf " - Done.\n"