The cli scripts in moodle code read the config.php file of the moodle + require other libraries for cli commands, thus one has to be in the moodle code directory when the those cli scripts are executed. Check out the upgrade.php file in moodlecode/admin/cli/ and you'll see the lines that require other moodle code.
Run the cron job before doing anything related to update/upgrade/git. When I first created the bash shell script I use, cron would not run if in the maintenance mode.
Git will acquire core code only ... unless you installed a plugin via git. The actual changes to the DB happen only when the upgrade.php is called. Not sure you need the git stash/git diff as git does show what files it's adding/changing, etc..
Note: you can test the git acquistion of code outside of the production moodle code on the same server or even on a workstation .. I have a Mac with git installed and a MDLTEST directory where I test the acquistion of new code for moodle versions.
cd /pathto/test/code/dir/
git pull
Here's what it shows:
Kens-MacBook-Pro:moodle33 ktask$ git pull
remote: Counting objects: 1164, done.
remote: Compressing objects: 100% (175/175), done.
remote: Total 755 (delta 577), reused 753 (delta 575)
Receiving objects: 100% (755/755), 179.33 KiB | 0 bytes/s, done.
Resolving deltas: 100% (577/577), completed with 137 local objects.
From git://git.moodle.org/moodle
5012651..2f0bd18 MOODLE_33_STABLE -> origin/MOODLE_33_STABLE
cc60733..469c46a MOODLE_32_STABLE -> origin/MOODLE_32_STABLE
91cbdda..22e99d6 master -> origin/master
Updating 5012651..2f0bd18
Fast-forward
admin/tool/mobile/classes/api.php | 11 +-
competency/classes/api.php | 3 +-
competency/tests/api_test.php | 15 +-
install/lang/mi/langconfig.php | 33 +++++
install/lang/oc_lnc/admin.php | 6 +-
install/lang/oc_lnc/error.php | 2 +-
install/lang/oc_lnc/install.php | 6 +-
install/lang/sv_fi/install.php | 1 +
lib/accesslib.php | 35 +++--
lib/tests/accesslib_test.php | 160 +++++++++++++++++++++
login/signup_form.php | 4 +-
mod/chat/classes/external.php | 3 +-
mod/chat/tests/externallib_test.php | 7 +-
mod/folder/edit.php | 6 +-
.../manualgraded/tests/walkthrough_test.php | 39 +++++
question/behaviour/rendererbase.php | 2 -
search/classes/document.php | 2 +
theme/boost/scss/preset/default.scss | 1 +
version.php | 4 +-
19 files changed, 306 insertions(+), 34 deletions(-)
create mode 100644 install/lang/mi/langconfig.php
Kens-MacBook-Pro:moodle33 ktask$
The version.php file always shows 4 +- cause only the lines in version.php file that relate to versioning are changed.
And, in my scripts I sometimes add a line:
fgrep '$release' version.php to see the version aquired by git.
Kens-MacBook-Pro:moodle33 ktask$ fgrep '$release' version.php
$release = '3.3.2+ (Build: 20170922)'; // Human-friendly version name
I also have in some scripts:
Kens-MacBook-Pro:moodle33 ktask$ git branch -a |head -n 1
To assure the master branch is pointed correctly.
I have, in the past, inserted a pause at that point to assure myself git has acquired the version of code desired.
Both an update script and an upgrade script are pretty much like a batch file in Windows and really (IMHO) don't need branching. Update script without backups won't change. It's the upgrade script that would require either input to the script and checking that input or editing prior to executing.
Uhhhh ... think one will be updating more often than upgrading.
Me leaving the upgrae scripts in a state that require editing ... ie, changing the backup file names, and the informational echo statements means I have to see them. Helps prevent me from 'out-smarting' myself1
Again ... my 2 cents.
'spirit of sharing', Ken