Let's consider that [] is the default test idiom when combined with if
This commit is contained in:
parent
90e3bc188f
commit
42bb96d005
|
@ -116,7 +116,7 @@ get_repository_status() {
|
|||
# tell Git where to find the repository and the work tree (no need to `cd …` there)
|
||||
export GIT_DIR="${dir}/.git" GIT_WORK_TREE="${dir}"
|
||||
# If the repository and the work tree exist, try to commit changes
|
||||
if test -d "${GIT_DIR}" && test -d "${GIT_WORK_TREE}"; then
|
||||
if [ -d "${GIT_DIR}" ] && [ -d "${GIT_WORK_TREE}" ]; then
|
||||
CHANGED_LINES=$(${GIT_BIN} status --porcelain | wc -l | tr -d ' ')
|
||||
if [ "${CHANGED_LINES}" != "0" ]; then
|
||||
STATUS=$(${GIT_BIN} status --short | tail -n 10)
|
||||
|
@ -154,13 +154,13 @@ END
|
|||
}
|
||||
|
||||
hook_commit() {
|
||||
if test -x "${GIT_BIN}"; then
|
||||
if [ -x "${GIT_BIN}" ]; then
|
||||
# loop on possible directories managed by GIT
|
||||
for dir in ${GIT_REPOSITORIES}; do
|
||||
# tell Git where to find the repository and the work tree (no need to `cd …` there)
|
||||
export GIT_DIR="${dir}/.git" GIT_WORK_TREE="${dir}"
|
||||
# If the repository and the work tree exist, try to commit changes
|
||||
if test -d "${GIT_DIR}" && test -d "${GIT_WORK_TREE}"; then
|
||||
if [ -d "${GIT_DIR}" ] && [ -d "${GIT_WORK_TREE}" ]; then
|
||||
CHANGED_LINES=$(${GIT_BIN} status --porcelain | wc -l | tr -d ' ')
|
||||
if [ "${CHANGED_LINES}" != "0" ]; then
|
||||
if [ "${DRY_RUN}" = "1" ]; then
|
||||
|
@ -180,6 +180,7 @@ hook_commit() {
|
|||
# unset environment variables to prevent accidental influence on other git commands
|
||||
unset GIT_DIR GIT_WORK_TREE
|
||||
done
|
||||
|
||||
if [ -n "${GIT_COMMITS}" ]; then
|
||||
if [ "${VERBOSE}" = "1" ]; then
|
||||
printf "\n\n********** Commits ****************\n%s\n***********************************\n" "${GIT_COMMITS}"
|
||||
|
@ -359,11 +360,11 @@ GIT_REPOSITORIES="/etc /etc/bind"
|
|||
# initialize variable
|
||||
GIT_STATUSES=""
|
||||
# git statuses
|
||||
if test -x "${GIT_BIN}"; then
|
||||
if [ -x "${GIT_BIN}" ]; then
|
||||
# loop on possible directories managed by GIT
|
||||
for dir in ${GIT_REPOSITORIES}; do
|
||||
RESULT=$(get_repository_status "${dir}")
|
||||
if test -n "${RESULT}"; then
|
||||
if [ -n "${RESULT}" ]; then
|
||||
# append diff data, without empty lines
|
||||
GIT_STATUSES=$(printf "%s\n%s\n" "${GIT_STATUSES}" "${RESULT}" | sed -e '/^$/d')
|
||||
fi
|
||||
|
@ -385,7 +386,7 @@ if [ -z "${MESSAGE}" ] && [ "${INTERACTIVE}" = "1" ]; then
|
|||
read -r MESSAGE
|
||||
fi
|
||||
|
||||
if test -z "${MESSAGE}"; then
|
||||
if [ -z "${MESSAGE}" ]; then
|
||||
echo "no value..."
|
||||
exit 1
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue