2019-04-25 12:45:16 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# file: git-add.sh
|
|
|
|
#
|
2019-04-25 13:17:35 +00:00
|
|
|
# works together with git pre-push.sh and ADD all changed files since last push
|
2019-04-25 12:45:16 +00:00
|
|
|
|
2021-01-03 21:39:36 +00:00
|
|
|
#### $$VERSION$$ v1.21-0-gc85af77
|
2019-04-25 12:45:16 +00: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 10:07:06 +00:00
|
|
|
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
|
|
|
if [ "$GIT_DIR" != "" ] ; then
|
|
|
|
cd "$GIT_DIR/.." || exit 1
|
|
|
|
else
|
2021-01-01 10:27:54 +00:00
|
|
|
printf "Sorry, no git repository %s\n" "$(pwd)" && exit 1
|
2019-05-11 10:07:06 +00:00
|
|
|
fi
|
2019-04-25 12:45:16 +00:00
|
|
|
|
2021-01-01 10:27:54 +00:00
|
|
|
[ ! -f .git/.lastcommit ] && printf "No previous commit or hooks not installed, use \"git add\" instead ... Abort\n" && exit
|
2019-05-01 10:15:10 +00:00
|
|
|
|
2020-12-15 09:40:20 +00:00
|
|
|
set +f
|
2021-01-03 11:06:39 +00:00
|
|
|
FILES="$(find ./* -newer .git/.lastcommit| grep -v -e 'DIST\/' -e 'STANDALONE\/' -e 'JSON.sh')"
|
2020-12-15 09:40:20 +00:00
|
|
|
set -f
|
|
|
|
# FILES="$(find ./* -newer .git/.lastpush)"
|
2021-01-01 10:27:54 +00:00
|
|
|
[ "${FILES}" = "" ] && printf "Nothing changed since last commit ...\n" && exit
|
2019-04-25 12:45:16 +00:00
|
|
|
|
2019-04-25 13:39:42 +00:00
|
|
|
# run pre_commit on files
|
|
|
|
dev/hooks/pre-commit.sh
|
|
|
|
|
2021-01-01 10:27:54 +00:00
|
|
|
printf "Add files to repo: "
|
2019-04-25 12:45:16 +00:00
|
|
|
# shellcheck disable=SC2086
|
2019-04-25 13:39:42 +00:00
|
|
|
for file in ${FILES}
|
|
|
|
do
|
|
|
|
[ -d "${file}" ] && continue
|
2021-01-01 10:27:54 +00:00
|
|
|
printf "%s" "${file} "
|
2020-12-24 11:13:53 +00:00
|
|
|
git add "$file"
|
2019-04-25 13:39:42 +00:00
|
|
|
done
|
2021-01-01 10:27:54 +00:00
|
|
|
printf " - Done.\n"
|
2019-04-25 12:45:16 +00:00
|
|
|
|