You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcpcfg/scripts/diff

45 lines
1.4 KiB

#!/bin/bash
# Purpose: show changes in configuration pool
################################################################################
set -e
set -u
set -o pipefail
# support testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}"
SCRIPTS="${SCRIPTS:-/usr/share/ngcp-ngcpcfg/scripts/}"
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}" >&2
exit 1
fi
timestamp_replacementchars=''
# shellcheck disable=SC1090
. "${FUNCTIONS}"/main
# main script
log_debug "cd $NGCPCTL_MAIN"
cd "$NGCPCTL_MAIN"
log_debug "git diff $*"
git diff "$@"
# added files
log_debug "git status --porcelain | awk '/^\?\? / {print \$2}'"
if git status --porcelain | awk '/^\?\? / {print $2}' | grep -q . ; then
log_info "* New but not yet registered files inside ${NGCPCTL_MAIN}:"
git status --porcelain | awk '/^\?\? / {print $2}' | sed "s/^/$timestamp_replacementchars/"
fi
# deleted files
log_debug "git status --porcelain | awk '/^D / {print \$2}'"
if git status --porcelain | awk '/^D / {print $2}' | grep -q . ; then
log_info "* Removed but not yet unregistered files inside ${NGCPCTL_MAIN}:"
git status --porcelain | awk '/^D / {print $2}' | sed "s/^/$timestamp_replacementchars/"
fi
## END OF FILE #################################################################