[cmd_update] [cmd_deploy] [cmd_exclude] [cmd_include] [cmd_fsck] Now makes sure git_dir being used is indeed the right repo

This commit is contained in:
ayakael 2018-05-16 00:09:46 -07:00
parent 9df4e5fb0d
commit cf5127a59a
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026
6 changed files with 7 additions and 1 deletions

View file

@ -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))

View file

@ -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[@]})"

View file

@ -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}"

View file

@ -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

View file

@ -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}"

View file

@ -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