diff --git a/src/cmd_deploy b/src/cmd_deploy index c2a65e4..3dc7f37 100644 --- a/src/cmd_deploy +++ b/src/cmd_deploy @@ -18,13 +18,14 @@ cmd_deploy() { local DB_FILE="${TARGET}/${_OPT_DB_FILE}" [[ ! -f "${DB_FILE}" ]] && return 3 [[ ! -d "${GIT_DIR}/.git" ]] && return 2 + [[ "$(git -C "${GIT_DIR}" rev-list HEAD | tail -n 1)" != "$(awk 'BEGIN{FS="\t"}{if($1=="REPO_ID"){print $2}}' "${DB_FILE}")" ]] && return 2 if [[ -z "$(grep LAST_DEPLOY ${DB_FILE})" ]]; then echo -e "LAST_DEPLOY\t$(git -C "${GIT_DIR}" rev-list HEAD | tail -n 1)" >> ${DB_FILE} fi local NEW_COMMIT=$(git -C "${GIT_DIR}" rev-parse HEAD) - [[ -z "${OLD_COMMIT}" ]] && local OLD_COMMIT=$(awk 'BEGIN{FS="\t"}{if($1=="LAST_DEPLOY"){print $2}}' ${DB_FILE}) + [[ -z "${OLD_COMMIT}" ]] && local OLD_COMMIT=$(awk 'BEGIN{FS="\t"}{if($1=="LAST_DEPLOY"){print $2}}' "${DB_FILE}") local removableidList=($(awk 'BEGIN{FS="\t"}{if(($1=="null" || $1=="false") && $4!="null"){print $2"--"$3}}' "${DB_FILE}")) local deployableidList=($(awk 'BEGIN{FS="\t"}{if($1=="true" && $4=="null"){print $2}}' "${DB_FILE}" | awk '!seen[$0]++')) local changedidList=($(sed 's/\(.*\)\..*/\1/' <<< $(git -C "${GIT_DIR}" diff --name-only ${NEW_COMMIT} ${OLD_COMMIT}) | awk '!seen[$0]++' | grep SHA256)) diff --git a/src/cmd_du b/src/cmd_du index 3ea31ab..186c611 100644 --- a/src/cmd_du +++ b/src/cmd_du @@ -16,6 +16,7 @@ cmd_du() { local DB_FILE="${TARGET}/${_OPT_DB_FILE}" [[ ! -f "${DB_FILE}" ]] && return 3 [[ ! -d "${GIT_DIR}/.git" ]] && return 2 + [[ "$(git -C "${GIT_DIR}" rev-list HEAD | tail -n 1)" != "$(awk 'BEGIN{FS="\t"}{if($1=="REPO_ID"){print $2}}' "${DB_FILE}")" ]] && return 2 local imageidList=($(awk 'BEGIN{FS="\t"}{if($1=="true"){print $2}}' ${DB_FILE} | awk '!seen[$0]++')) local DU="$(print_imageid_du ${GIT_DIR} ${imageidList[@]})" diff --git a/src/cmd_exclude b/src/cmd_exclude index 7fc44ae..65c9426 100644 --- a/src/cmd_exclude +++ b/src/cmd_exclude @@ -22,6 +22,7 @@ cmd_exclude() { local conditionList=("${@}") [[ ! -f "${DB_FILE}" ]] && return 3 [[ ! -d "${GIT_DIR}/.git" ]] && return 2 + [[ "$(git -C "${GIT_DIR}" rev-list HEAD | tail -n 1)" != "$(awk 'BEGIN{FS="\t"}{if($1=="REPO_ID"){print $2}}' "${DB_FILE}")" ]] && return 2 for condition in ${conditionList[@]}; do _msg EXEC "Excluding all tracks that match the following condition: ${condition}" diff --git a/src/cmd_fsck b/src/cmd_fsck index a372169..0a526ee 100644 --- a/src/cmd_fsck +++ b/src/cmd_fsck @@ -17,6 +17,7 @@ cmd_fsck() { local DB_FILE="${TARGET}/${_OPT_DB_FILE}" [[ ! -f "${DB_FILE}" ]] && return 3 [[ ! -d "${GIT_DIR}/.git" ]] && return 2 + [[ "$(git -C "${GIT_DIR}" rev-list HEAD | tail -n 1)" != "$(awk 'BEGIN{FS="\t"}{if($1=="REPO_ID"){print $2}}' "${DB_FILE}")" ]] && return 2 for cmd in ${cmdList[@]}; do case ${cmd} in diff --git a/src/cmd_include b/src/cmd_include index 720a228..166fdd8 100644 --- a/src/cmd_include +++ b/src/cmd_include @@ -22,6 +22,7 @@ cmd_include() { local conditionList=("${@}") [[ ! -f "${DB_FILE}" ]] && return 3 [[ ! -d "${GIT_DIR}/.git" ]] && return 2 + [[ "$(git -C "${GIT_DIR}" rev-list HEAD | tail -n 1)" != "$(awk 'BEGIN{FS="\t"}{if($1=="REPO_ID"){print $2}}' "${DB_FILE}")" ]] && return 2 for condition in ${conditionList[@]}; do _msg EXEC "Including all tracks that match the following condition: ${condition}" diff --git a/src/cmd_update b/src/cmd_update index bb9ab09..deff330 100644 --- a/src/cmd_update +++ b/src/cmd_update @@ -17,6 +17,7 @@ cmd_update() { local DB_FILE="${TARGET}/${_OPT_DB_FILE}" [[ ! -f "${DB_FILE}" ]] && return 3 [[ ! -d "${GIT_DIR}/.git" ]] && return 2 + [[ "$(git -C "${GIT_DIR}" rev-list HEAD | tail -n 1)" != "$(awk 'BEGIN{FS="\t"}{if($1=="REPO_ID"){print $2}}' "${DB_FILE}")" ]] && return 2 # In the event that LAST_COMMIT OR DB_FILE does not exist, echo out that the LAST_COMMIT # is the first COMMIT of GIT_DIR, thus stating that no database update has ever occured