@@ -3,11 +3,11 @@ set -Eeuo pipefail
33IFS=$' \n\t '
44
55update_self () {
6- local BRANCH CurrentBranch
6+ local BRANCH CurrentBranch CurrentVersion RemoteVersion
77 BRANCH=${1-}
88 pushd " ${SCRIPTPATH} " & > /dev/null || fatal " Failed to change directory.\nFailing command: ${F[C]} push \" ${SCRIPTPATH} \" "
99 CurrentBranch=" $( git branch --show) "
10- popd & > /dev/null
10+ CurrentVersion= " $( ds_version ) "
1111
1212 local Title=" Update ${APPLICATION_NAME} "
1313 local Question YesNotice NoNotice
@@ -16,17 +16,35 @@ update_self() {
1616 error " You need to specify a branch to update to."
1717 return 1
1818 fi
19- Question=" Would you like to update ${APPLICATION_NAME} to current branch ${CurrentBranch} now?"
19+ RemoteVersion=" $( ds_version " ${CurrentBranch} " ) "
20+ Question=" Would you like to update ${APPLICATION_NAME} from ${CurrentVersion} to ${RemoteVersion} now?"
2021 NoNotice=" ${APPLICATION_NAME} will not be updated."
21- YesNotice=" Updating ${APPLICATION_NAME} to branch ${CurrentBranch } ."
22+ YesNotice=" Updating ${APPLICATION_NAME} from ${CurrentVersion} to ${RemoteVersion } ."
2223 elif [[ ${BRANCH-} == " ${CurrentBranch-} " ]]; then
23- Question=" Would you like to forcefully update ${APPLICATION_NAME} to current branch ${BRANCH} now?"
24- NoNotice=" ${APPLICATION_NAME} will not be updated."
25- YesNotice=" Updating ${APPLICATION_NAME} to branch ${BRANCH} ."
24+ RemoteVersion=" $( ds_version " ${CurrentBranch} " ) "
25+ if [[ ${CurrentVersion} == " ${RemoteVersion} " ]]; then
26+ Question=" Would you like to forcefully re-apply ${APPLICATION_NAME} update ${CurrentVersion} ?"
27+ NoNotice=" ${APPLICATION_NAME} will not be updated."
28+ YesNotice=" Updating ${APPLICATION_NAME} to ${RemoteVersion} ."
29+ fi
2630 else
27- Question=" Would you like to update ${APPLICATION_NAME} from branch ${CurrentBranch} to ${BRANCH} now?"
28- NoNotice=" ${APPLICATION_NAME} will not be updated from branch ${CurrentBranch} to ${BRANCH} ."
29- YesNotice=" Updating ${APPLICATION_NAME} from branch ${CurrentBranch} to ${BRANCH} ."
31+ RemoteVersion=" $( ds_version " ${BRANCH} " ) "
32+ Question=" Would you like to update ${APPLICATION_NAME} from ${CurrentVersion} to ${RemoteVersion} now?"
33+ NoNotice=" ${APPLICATION_NAME} will not be updated from ${CurrentVersion} to ${RemoteVersion} ."
34+ YesNotice=" Updating ${APPLICATION_NAME} from ${CurrentVersion} to ${RemoteVersion} ."
35+ fi
36+ popd & > /dev/null
37+ if [[ -z ${BRANCH-} && ${CurrentVersion} == " ${RemoteVersion} " ]]; then
38+ if use_dialog_box; then
39+ {
40+ notice " ${APPLICATION_NAME} is already up to date on branch ${BRANCH} ."
41+ notice " Current version is ${CurrentVersion} "
42+ } | & dialog_pipe " ${DC[TitleWarning]}${Title} " " ${DC[CommandLine]} ds --update $* "
43+ else
44+ notice " ${APPLICATION_NAME} is already up to date on branch ${CurrentBranch} ."
45+ notice " Current version is ${CurrentVersion} "
46+ fi
47+ return
3048 fi
3149 if ! run_script ' question_prompt' Y " ${Question} " " ${Title} " " ${FORCE: +Y} " ; then
3250 if use_dialog_box; then
@@ -48,17 +66,8 @@ update_self() {
4866commands_update_self () {
4967 local BRANCH=${1-}
5068 local Notice=${2-}
51- local CurrentBranch
5269
5370 pushd " ${SCRIPTPATH} " & > /dev/null || fatal " Failed to change directory.\nFailing command: ${F[C]} push \" ${SCRIPTPATH} \" "
54- if [[ -z ${BRANCH-} ]]; then
55- BRANCH=" $( git branch --show) "
56- if ! ds_update_available; then
57- notice " ${APPLICATION_NAME} is already up to date on branch ${BRANCH} ."
58- notice " Current version is $( ds_version) "
59- return
60- fi
61- fi
6271 local QUIET=' '
6372 if [[ -z ${VERBOSE-} ]]; then
6473 QUIET=' --quiet'
@@ -93,7 +102,7 @@ commands_update_self() {
93102 git ls-tree -rt --name-only " ${BRANCH} " | xargs sudo chown " ${DETECTED_PUID} " :" ${DETECTED_PGID} " > /dev/null 2>&1 || true
94103 sudo chown -R " ${DETECTED_PUID} " :" ${DETECTED_PGID} " " ${SCRIPTPATH} /.git" > /dev/null 2>&1 || true
95104 sudo chown " ${DETECTED_PUID} " :" ${DETECTED_PGID} " " ${SCRIPTPATH} " > /dev/null 2>&1 || true
96- notice " Updated to $( ds_version) "
105+ notice " Updated to [ $( ds_version) ] "
97106 popd & > /dev/null
98107 exec bash " ${SCRIPTNAME} " -e
99108}
0 commit comments