telegram-bot-bash/dev/git-add.sh

38 lines
1.0 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# file: git-add.sh
#
# works together with git pre-push.sh and ADD all changed files since last push
2020-12-24 11:13:53 +00:00
#### $$VERSION$$ v1.2-dev2-64-gf4d64f7
# 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
echo "Sorry, no git repository $(pwd)" && exit 1
fi
2020-12-24 11:13:53 +00:00
[ ! -f .git/.lastcommit ] && echo "No previous commit or hooks not installed, use \"git add\" instead ... Abort" && exit
2019-05-01 10:15:10 +00:00
set +f
FILES="$(find ./* -newer .git/.lastpush| grep -v -e 'DIST\/' -e 'STANDALONE\/' -e 'JSON.sh')"
set -f
# FILES="$(find ./* -newer .git/.lastpush)"
2020-12-24 11:13:53 +00:00
[ "${FILES}" = "" ] && echo "Noting changed since last commit ..." && exit
2019-04-25 13:39:42 +00:00
# run pre_commit on files
dev/hooks/pre-commit.sh
2020-12-24 11:13:53 +00:00
echo -e "Add files to repo: \c"
# shellcheck disable=SC2086
2019-04-25 13:39:42 +00:00
for file in ${FILES}
do
[ -d "${file}" ] && continue
2020-12-24 11:13:53 +00:00
echo -e "${file} \c"
git add "$file"
2019-04-25 13:39:42 +00:00
done
2020-12-24 11:13:53 +00:00
echo " - Done."