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

40 lines
925 B
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
2021-03-10 08:39:17 +01:00
#### $$VERSION$$ v1.5-0-g8adca9b
2021-01-15 14:23:19 +01:00
#shellcheck disable=SC1090
source "${0%/*}/dev.inc.sh"
2021-01-19 18:09:45 +01:00
# check for last commit date
if [ ! -f "${LASTCOMMIT}" ]; then
if ! touch -d "$(git log -1 --format=%cD)" "${LASTCOMMIT}"; then
printf "No previous commit found, use \"git add\" instead ... Abort\n"
exit
fi
fi
2019-05-01 12:15:10 +02:00
set +f
2021-01-19 18:09:45 +01:00
FILES="$(find ./* -newer "${LASTCOMMIT}" | grep -v -e 'DIST\/' -e 'STANDALONE\/' -e 'JSON.sh')"
set -f
# FILES="$(find ./* -newer .git/.lastpush)"
2021-01-01 11:27:54 +01:00
[ "${FILES}" = "" ] && printf "Nothing changed since last commit ...\n" && exit
2019-04-25 15:39:42 +02:00
# run pre_commit on files
dev/hooks/pre-commit.sh
2021-01-01 11:27:54 +01:00
printf "Add files to repo: "
# shellcheck disable=SC2086
2019-04-25 15:39:42 +02:00
for file in ${FILES}
do
[ -d "${file}" ] && continue
2021-01-01 11:27:54 +01:00
printf "%s" "${file} "
2019-04-25 15:39:42 +02:00
done
2021-01-01 11:27:54 +01:00
printf " - Done.\n"
# stay with "." for (re)moved files!
git add .