[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:
parent
9df4e5fb0d
commit
cf5127a59a
6 changed files with 7 additions and 1 deletions
|
@ -18,13 +18,14 @@ cmd_deploy() {
|
||||||
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
||||||
[[ ! -f "${DB_FILE}" ]] && return 3
|
[[ ! -f "${DB_FILE}" ]] && return 3
|
||||||
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
|
[[ ! -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
|
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}
|
echo -e "LAST_DEPLOY\t$(git -C "${GIT_DIR}" rev-list HEAD | tail -n 1)" >> ${DB_FILE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local NEW_COMMIT=$(git -C "${GIT_DIR}" rev-parse HEAD)
|
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 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 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))
|
local changedidList=($(sed 's/\(.*\)\..*/\1/' <<< $(git -C "${GIT_DIR}" diff --name-only ${NEW_COMMIT} ${OLD_COMMIT}) | awk '!seen[$0]++' | grep SHA256))
|
||||||
|
|
|
@ -16,6 +16,7 @@ cmd_du() {
|
||||||
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
||||||
[[ ! -f "${DB_FILE}" ]] && return 3
|
[[ ! -f "${DB_FILE}" ]] && return 3
|
||||||
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
|
[[ ! -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 imageidList=($(awk 'BEGIN{FS="\t"}{if($1=="true"){print $2}}' ${DB_FILE} | awk '!seen[$0]++'))
|
||||||
local DU="$(print_imageid_du ${GIT_DIR} ${imageidList[@]})"
|
local DU="$(print_imageid_du ${GIT_DIR} ${imageidList[@]})"
|
||||||
|
|
|
@ -22,6 +22,7 @@ cmd_exclude() {
|
||||||
local conditionList=("${@}")
|
local conditionList=("${@}")
|
||||||
[[ ! -f "${DB_FILE}" ]] && return 3
|
[[ ! -f "${DB_FILE}" ]] && return 3
|
||||||
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
|
[[ ! -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
|
for condition in ${conditionList[@]}; do
|
||||||
_msg EXEC "Excluding all tracks that match the following condition: ${condition}"
|
_msg EXEC "Excluding all tracks that match the following condition: ${condition}"
|
||||||
|
|
|
@ -17,6 +17,7 @@ cmd_fsck() {
|
||||||
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
||||||
[[ ! -f "${DB_FILE}" ]] && return 3
|
[[ ! -f "${DB_FILE}" ]] && return 3
|
||||||
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
|
[[ ! -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
|
for cmd in ${cmdList[@]}; do
|
||||||
case ${cmd} in
|
case ${cmd} in
|
||||||
|
|
|
@ -22,6 +22,7 @@ cmd_include() {
|
||||||
local conditionList=("${@}")
|
local conditionList=("${@}")
|
||||||
[[ ! -f "${DB_FILE}" ]] && return 3
|
[[ ! -f "${DB_FILE}" ]] && return 3
|
||||||
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
|
[[ ! -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
|
for condition in ${conditionList[@]}; do
|
||||||
_msg EXEC "Including all tracks that match the following condition: ${condition}"
|
_msg EXEC "Including all tracks that match the following condition: ${condition}"
|
||||||
|
|
|
@ -17,6 +17,7 @@ cmd_update() {
|
||||||
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
|
||||||
[[ ! -f "${DB_FILE}" ]] && return 3
|
[[ ! -f "${DB_FILE}" ]] && return 3
|
||||||
[[ ! -d "${GIT_DIR}/.git" ]] && return 2
|
[[ ! -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
|
# 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
|
# is the first COMMIT of GIT_DIR, thus stating that no database update has ever occured
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue