2019-04-25 14:45:16 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# file: git-add.sh
|
|
|
|
#
|
2019-04-25 15:17:35 +02:00
|
|
|
# works together with git pre-push.sh and ADD all changed files since last push
|
2019-04-25 14:45:16 +02:00
|
|
|
|
2019-05-22 18:43:20 +02:00
|
|
|
#### $$VERSION$$ v0.90-dev-0-g75691dc
|
2019-04-25 14:45:16 +02:00
|
|
|
|
|
|
|
# magic to ensure that we're always inside the root of our application,
|
|
|
|
# no matter from which directory we'll run script
|
2019-05-11 12:07:06 +02:00
|
|
|
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
|
2019-04-25 14:45:16 +02:00
|
|
|
|
2019-05-02 15:14:18 +02:00
|
|
|
[ ! -f .git/.lastpush ] && echo "No push or hooks not installed, use \"git add\" instead ... Abort" && exit
|
2019-05-01 12:15:10 +02:00
|
|
|
|
2019-04-25 14:45:16 +02:00
|
|
|
FILES="$(find ./* -newer .git/.lastpush)"
|
2019-05-01 12:15:10 +02:00
|
|
|
[ "${FILES}" = "" ] && echo "Noting changed since last push ... Abort" && exit
|
2019-04-25 14:45:16 +02:00
|
|
|
|
2019-04-25 15:39:42 +02:00
|
|
|
# run pre_commit on files
|
|
|
|
dev/hooks/pre-commit.sh
|
|
|
|
|
|
|
|
echo -n "Add files to repo: "
|
2019-04-25 14:45:16 +02:00
|
|
|
# shellcheck disable=SC2086
|
2019-04-25 15:39:42 +02:00
|
|
|
for file in ${FILES}
|
|
|
|
do
|
|
|
|
[ -d "${file}" ] && continue
|
2019-04-26 11:28:51 +02:00
|
|
|
echo -n "${file} "
|
2019-04-25 15:39:42 +02:00
|
|
|
done
|
2019-04-26 11:28:51 +02:00
|
|
|
git add .
|
2019-04-25 15:39:42 +02:00
|
|
|
echo "done."
|
2019-04-25 14:45:16 +02:00
|
|
|
|