From 986030b1f2739c8cab1f21b008b22272f45160be Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Fri, 11 Sep 2015 10:47:55 +0200 Subject: [PATCH] MT#15141 Add check for merge failures Change-Id: Id078f26296208a0dac2112e9f2a0066dbe835984 --- scripts/check | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/check b/scripts/check index bf71d13b..ccee78a8 100755 --- a/scripts/check +++ b/scripts/check @@ -9,12 +9,12 @@ set -u FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}" HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}" -if ! [ -r ${FUNCTIONS}/main ] ; then - printf "Error: ${FUNCTIONS}/main could not be read. Exiting.\n" >&2 +if ! [ -r "${FUNCTIONS}"/main ] ; then + printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}" >&2 exit 1 fi -. ${FUNCTIONS}/main +. "${FUNCTIONS}"/main check_config_encoding() { log_debug "Checking encoding for $config_files" @@ -58,7 +58,8 @@ validate_config() { log_debug "Validating schema for main YAML files" for f in $config_files ; do - local schema="/usr/share/ngcp-cfg-schema/validate/$(basename "${f}")" + local schema + schema="/usr/share/ngcp-cfg-schema/validate/$(basename "${f}")" if ! [ -f "${schema}" ] ; then continue @@ -81,6 +82,18 @@ validate_config() { fi } +check_configs_conflicts() { + log_info "Checking merge conflicts in ngcp configs:" + if grep -rP --exclude-dir='.git' --exclude='*.dpkg-*' \ + '^>>>>>>> [0-9a-fA-F]+' /etc/ngcp-config/ 2>&1 + then + log_error "ERROR: ngcp configs with Git merge conflicts found." + exit 1 + else + log_info "No ngcp configs with merge conflicts found." + fi +} + if [ "$*" = "" ] ; then config_files="${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES:-} ${CONSTANTS_CONFIG:-}" else @@ -91,6 +104,7 @@ check_configs if "${VALIDATE_SCHEMA:-false}" ; then validate_config fi +check_configs_conflicts exit 0