change output
This commit is contained in:
parent
cd68bfbc72
commit
e4e3a3bafa
1 changed files with 19 additions and 46 deletions
|
@ -20,6 +20,14 @@
|
|||
[ -z "${MYSHELLCONFIG_GIT_REMOTE_NAME+x}" ] && export MYSHELLCONFIG_GIT_REMOTE_NAME=origin
|
||||
[ -z "${MYSHELLCONFIG_GIT_BRANCH+x}" ] && export MYSHELLCONFIG_GIT_BRANCH=master
|
||||
|
||||
gitupdateend() {
|
||||
cat << EOF >> "${MYSHELLCONFIG_LOGFILE}"
|
||||
|
||||
+-----ENDE git update repo $(date) ---------------------------------+
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
ENTRY
|
||||
cat << EOF >> "${MYSHELLCONFIG_LOGFILE}"
|
||||
+-----BEGINN git update repo $(date) -------------------------------+
|
||||
|
@ -50,7 +58,7 @@ if [ $updated -lt $(date --date="${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_INTERVALL
|
|||
fi
|
||||
|
||||
#echo $SGIT fetch ${MYSHELLCONFIG_GIT_REMOTE_NAME} -p 1>&2
|
||||
$SGIT fetch ${GIT_FETCH_OPTIONS} ${MYSHELLCONFIG_GIT_REMOTE_NAME} -p 2>>"${MYSHELLCONFIG_LOGFILE}"|| { logwarn fetch failed; exit 1; }
|
||||
$SGIT fetch ${GIT_FETCH_OPTIONS} ${MYSHELLCONFIG_GIT_REMOTE_NAME} -p 2>>"${MYSHELLCONFIG_LOGFILE}"|| { logwarn fetch failed; gitupdateend; exit 1; }
|
||||
|
||||
echo "Check for local changes:" >> "${MYSHELLCONFIG_LOGFILE}"
|
||||
if $SGIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MYSHELLCONFIG_LOGFILE}" ; then
|
||||
|
@ -58,8 +66,8 @@ if $SGIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MYSHELLCONFIG_
|
|||
no changes in local repo
|
||||
$SGIT checkout repo ${PRE}${PRE:+/}${MYSHELLCONFIG_GIT_BRANCH}
|
||||
EOF
|
||||
$SGIT checkout ${PRE}${PRE:+/}${MYSHELLCONFIG_GIT_BRANCH} 1>>"${MYSHELLCONFIG_LOGFILE}" 2>>"${MYSHELLCONFIG_LOGFILE}"|| exit 2
|
||||
$SGIT merge FETCH_HEAD 1>>"${MYSHELLCONFIG_LOGFILE}" 2>>"${MYSHELLCONFIG_LOGFILE}"|| exit 3
|
||||
$SGIT checkout ${PRE}${PRE:+/}${MYSHELLCONFIG_GIT_BRANCH} 1>>"${MYSHELLCONFIG_LOGFILE}" 2>>"${MYSHELLCONFIG_LOGFILE}"|| { gitupdateend; exit 2; }
|
||||
$SGIT merge FETCH_HEAD 1>>"${MYSHELLCONFIG_LOGFILE}" 2>>"${MYSHELLCONFIG_LOGFILE}"|| { gitupdateend; exit 3; }
|
||||
else
|
||||
logwarn -n " Lokale Änderungen festgestellt:"
|
||||
echo " Siehe Logfile ${MYSHELLCONFIG_LOGFILE}" >&2
|
||||
|
@ -79,11 +87,7 @@ else
|
|||
$($SGIT diff-index -p HEAD --)
|
||||
EOF
|
||||
|
||||
cat << EOF >> "${MYSHELLCONFIG_LOGFILE}"
|
||||
|
||||
+-----ENDE git update repo $(date) ---------------------------------+
|
||||
|
||||
EOF
|
||||
gitupdateend
|
||||
exit 4
|
||||
|
||||
fi
|
||||
|
@ -91,48 +95,17 @@ fi
|
|||
loginfo -n "repo synced"
|
||||
|
||||
if ${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE-${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_DEFAULT-true}}; then
|
||||
# updated=$(cat ${MYSHELLCONFIG_BASE%/}${MYSHELLCONFIG_BASE:+/}.last_udate_submodules 2>/dev/null || echo 0 )
|
||||
# if [ $updated -lt $(date --date="${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_INTERVALL} hours ago" "+%s") ]; then
|
||||
logdebug "update submodules"
|
||||
rc=0
|
||||
# srv="${MYSHELLCONFIG_GIT_SUBMODULES_SERVER-${MYSHELLCONFIG_GIT_SUBMODULES_SERVER_DEFAULT}}"
|
||||
# logwarn "srv $srv"
|
||||
# $SGIT config --file=.gitmodules -l | \
|
||||
# grep url= | \
|
||||
# awk -F "=" -v srv="${srv%/}${srv:+/}" \
|
||||
# '{gsub(/^.*github.com\//,srv,$2); print $1" "$2}' | \
|
||||
# while read a b; do
|
||||
# logdebug "$SGIT config --file=.gitmodules ${a} ${b}"
|
||||
# $SGIT config --file=.gitmodules "${a}" "${b}"
|
||||
# done
|
||||
|
||||
# Submodules always have origin and master as repo and branch to track
|
||||
#$SGIT submodule init 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1|| { logwarn "update submodules failed on ini"; rc=5; }
|
||||
#$SGIT submodule foreach "git checkout master" 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1 || { logwarn "checkout master submodules failed on set upstream"; rc=7; }
|
||||
#$SGIT submodule foreach "git branch -u origin/master master" 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1|| { logwarn "set-upstream submodules failed on set upstream"; rc=8; }
|
||||
#$SGIT submodule update --init --recursive --remote --merge 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1 || { logwarn " update submodules failed on update"; rc=9; }
|
||||
|
||||
# run git submodule sync only ich local repo should use submodule urls from main-project
|
||||
# so don't use it here
|
||||
# logdebug "$($SGIT submodule sync)" || { logwarn "sync submodules failed on sync"; rc=6; }
|
||||
logdebug "$($SGIT submodule update --remote)"
|
||||
#logdebug "$($SGIT submodule update --init --recursive)"
|
||||
#logdebug "$($SGIT commit .gitmodules -m 'update submodules')"
|
||||
logdebug "$($SGIT commit -a -m 'update submodules')"
|
||||
#$SGIT submodule update --init --remote --merge 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1 || { logwarn " update submodules failed on update"; rc=9; }
|
||||
#$SGIT checkout .gitmodules
|
||||
logdebug "submodules updated successfully"
|
||||
loginfo -n ", submodules synced"
|
||||
date "+%s" > ${MYSHELLCONFIG_BASE%/}${MYSHELLCONFIG_BASE:+/}.last_udate_submodules
|
||||
else
|
||||
logdebug "submodules not updated. last update is less then ${MYSHELLCONFIG_GIT_SUBMODULE_UPDATE_INTERVALL} hours ago"
|
||||
fi
|
||||
|
||||
# else
|
||||
# loginfo -n ", submodules not synced"
|
||||
# logdebug "Do not update submodules. It's denied by environment MYSHELLCONFIG_GIT_UPDATE_SUBMODULES: ${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE-${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_DEFAULT-true}}"
|
||||
# logdebug "submodules not updated. last update is less then ${MYSHELLCONFIG_GIT_SUBMODULE_UPDATE_INTERVALL} hours ago"
|
||||
# fi
|
||||
loginfo -n ": "
|
||||
|
||||
else
|
||||
loginfo -n ", submodules not synced"
|
||||
logdebug "Do not update submodules. It's denied by environment MYSHELLCONFIG_GIT_UPDATE_SUBMODULES: ${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE-${MYSHELLCONFIG_GIT_SUBMODULES_UPDATE_DEFAULT-true}}"
|
||||
fi
|
||||
|
||||
EXIT
|
||||
exit $rc
|
||||
|
|
Loading…
Reference in a new issue