add option to force repoupdate
This commit is contained in:
parent
e95b3328dd
commit
46a8939e75
1 changed files with 44 additions and 38 deletions
|
@ -44,7 +44,11 @@ while [ $# -gt 0 ]; do
|
|||
PRE="${MSC_GIT_REMOTE_NAME}"
|
||||
shift
|
||||
;;
|
||||
-s|--submodules-update)
|
||||
-r|--force-repo-update)
|
||||
dosubmodupdate="true"
|
||||
shift
|
||||
;;
|
||||
-s|--force-submodules-update)
|
||||
dosubmodupdate="true"
|
||||
shift
|
||||
;;
|
||||
|
@ -68,7 +72,7 @@ done
|
|||
if [ $(stat --printf %Y ${MSC_GIT_UPD_SUBMOD_STATFILE} 2>/dev/null || echo 0 ) \
|
||||
-lt $(date --date="${MSC_GIT_SUBMODULES_UPDATE_INTERVALL-${MSC_GIT_SUBMODULES_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") \
|
||||
-a ${MSC_GIT_SUBMODULES_UPDATE-${MSC_GIT_SUBMODULES_UPDATE_DEFAULT-true}} ]; then
|
||||
[ -z "${dosrepoupdate+x}" ] && dorepoupdate="true"
|
||||
[ -z "${dorepoupdate+x}" ] && dorepoupdate="true"
|
||||
fi
|
||||
|
||||
if [ $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \
|
||||
|
@ -78,22 +82,23 @@ if [ $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \
|
|||
fi
|
||||
|
||||
#echo $SGIT fetch ${MSC_GIT_REMOTE_NAME} -p 1>&2
|
||||
loginfo "fetch repo${dosubmodupdate:+ and submodules}"
|
||||
$SGIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarn fetch failed; gitupdateend; exit 1; }
|
||||
if ${dosubmodupdate:-false}; then
|
||||
if $dorepoupdate; then
|
||||
loginfo "fetch repo${dosubmodupdate:+ and submodules}"
|
||||
$SGIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarn fetch failed; gitupdateend; exit 1; }
|
||||
if ${dosubmodupdate:-false}; then
|
||||
lastupdatesubmodules
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Check for local changes:" >> "${MSC_LOGFILE}"
|
||||
if $SGIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MSC_LOGFILE}" ; then
|
||||
echo "Check for local changes:" >> "${MSC_LOGFILE}"
|
||||
if $SGIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MSC_LOGFILE}" ; then
|
||||
cat << EOF >> "${MSC_LOGFILE}"
|
||||
no changes in local repo
|
||||
$SGIT checkout repo ${PRE}${PRE:+/}${MSC_GIT_BRANCH}
|
||||
EOF
|
||||
EOF
|
||||
$SGIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 2; }
|
||||
$SGIT merge FETCH_HEAD 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 3; }
|
||||
touch $MSC_GIT_UPD_REPO_STATFILE
|
||||
else
|
||||
else
|
||||
logwarn -n " Lokale Änderungen festgestellt:"
|
||||
echo " Siehe Logfile ${MSC_LOGFILE}" >&2
|
||||
cat << EOF >> "${MSC_LOGFILE}"
|
||||
|
@ -115,16 +120,17 @@ EOF
|
|||
gitupdateend
|
||||
exit 4
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
loginfo "repo${dosubmodupdate:+ and submodules} synced"
|
||||
loginfo "repo${dosubmodupdate:+ and submodules} synced"
|
||||
|
||||
if ${dosubmodupdate:-false}; then
|
||||
if ${dosubmodupdate:-false}; then
|
||||
loginfo "update and commit submodules"
|
||||
logdebug "$($SGIT submodule update --remote)"
|
||||
logdebug "$($SGIT commit -a -m 'update submodules')"
|
||||
touch $MSC_GIT_UPD_SUBMOD_STATFILE
|
||||
logwarn "submodules synced"
|
||||
fi
|
||||
fi
|
||||
|
||||
EXIT
|
||||
|
|
Loading…
Reference in a new issue