Moodle not recognizing git pull update

Moodle not recognizing git pull update

by Natassia Stelmaszek -
Number of replies: 6

I’m trying to update to Moodle 3.3 on my Beta (test) system and Moodle doesn’t seem to notice that I’ve updated the files using git.  I have been using git to install the Moodle code updates for over a year and this is the first time that it hasn’t worked.

Full disclosure.

Yesterday on my first attempt I tried doing the procedure from memory (should have known better) and ended up just updating to a newer version of 3.2.3+.  When I did that Moodle recognized the changes and gave me the opportunity to update the database and afterward, displayed the new build date (20150525) at the bottom of the Notifications page. 

During my next try, I followed the procedure (https://docs.moodle.org/33/en/Git_for_Administrators#Git_from_behind_a_firewall) but that didn’t seem to make any difference.  Today I ran git pull again, it downloaded updates but Moodle didn’t seem to recognize them.

What is it that Moodle looks at to tell that the code has been updated?

Referencing the Git for Administrators document, under the heading “Obtaining the code from Git” the first step says to “cd /path/to/your/webroot”.  Is webroot the directory holding the moodle code files that actually get executed?  Or is webroot the directory that holds the git local repository and the code that is executed is actually in the “moodle” directory that was created with Command (1) ?

git clone git://git.moodle.org/moodle.git

Natassia

Average of ratings: -
In reply to Natassia Stelmaszek

Re: Moodle not recognizing git pull update

by Ken Task -
Picture of Particularly helpful Moodlers

You should be in the directory where the moodle code resides.   There is a hidden 'dot'git directory located there.

How did you originally install?   with -b option restricts git to the branch 3.2.x.   Without the -b option you actually increase the size of the contents of .git directory, but you get all branches ... past as well as future ... including the dev branch.

cd /pathtomoodlecode/

git branch -a

will show what branch you are set to now at the top and below that all the branches git knows about.

The version of code is in the version.php file at the root of the moodle code ... where one finds config.php.

fgrep '$release' version.php will show the version of files.

'spirit of sharing', Ken

In reply to Ken Task

Re: Moodle not recognizing git pull update

by Natassia Stelmaszek -

Ken,

The original installation on this machine was done from the CLI using:

From the /var/www/html directory:

sudo git clone --depth=1 --single-branch -b MOODLE_32_STABLE git://git.moodle.org/moodle.git

Which left me with a /var/www/html/moodle directory that included the .git directory.

Somewhere along the line I wound up (probably through my own mistake but I'm not sure) with a /var/www/html/moodle/moodle directory which included a copy of the code along with another .git directory.  Is that normal or is that just an artifact that I should eliminate at my earliest opportunity?

The one thing that isn't spelled out in the Moodle Docs Git for Administrators is specifically how to add a new branch and switch to it if you already have a working system.  Now that I've been playing with it some more I suspect that when I was trying to do the update what I did was to cd into /var/www/html/moodle and then started with Command (1) from the Obtaining the code from Git section (shown below) of the document and that action created the second moodle directory (var/www/html/moodle/moodle).

I think that the right way to have done it was to start in the /var/www/html/moodle directory and use Command (3) and Command (4) to create the new branch and switch to it without re-downloading the code files.


$ cd /path/to/your/webroot
$ git clone git://git.moodle.org/moodle.git                       (1)
$ cd moodle
$ git branch -a                                                   (2)
$ git branch --track MOODLE_33_STABLE origin/MOODLE_33_STABLE     (3)
$ git checkout MOODLE_33_STABLE                                   (4)

Natassia

In reply to Natassia Stelmaszek

Re: Moodle not recognizing git pull update

by Ken Task -
Picture of Particularly helpful Moodlers

This:

git clone --depth=1 --single-branch -b MOODLE_32_STABLE

Set the hidden .git directory to one branch only ... 3.2.

One issues the git clone command only once.   And once the moodle directory is created by git all future commands for Moodle are issued inside the default 'moodle' directory.

The only thing one could do installing moodle with a single branch is to update it through the highest 3.2.x ... it will go no higher.

The reason for the other moodle directory inside moodle I think is because you repeated the entire process ... which begot yet another moodle directory.

So straightening this out is a little involved ... but can be done.

Before providing directions on how to do that you need to answer the following ... which 'moodle' directory is serving your Moodle?   When you go to http://site/moodle/ does moodle show or do you see a 'moodle' directory and when opening that with browser that's when you see the moodle?

'spirit of sharing', Ken


In reply to Natassia Stelmaszek

Re: Moodle not recognizing git pull update

by Ken Task -
Picture of Particularly helpful Moodlers

If one was installing moodle for the first time (example is for linux standards based box where apache's home directory is /var/www/ an the document root is html at that location.

cd /var/www/

git clone git://git.moodle.org/moodle.git htmlgit

cd htmlgit

git branch -a

git branch --track MOODLE_3#_STABLE origin/MOODLE_3#_STABLE

git checkout MOODLE_3#_STABLE

(where # is the specific version number)

You are in htmlgit

chown apache:apache * -R

cp -rp * ../html/

That should copy all files/diretories from the htmlgit directory to the html directory.

Just to make sure:

ls -la

if you see hidden .git directory or hidden .files of any kind, move them to html

still in htmlgit

mv .git ../html/

mv .other ../html/

ls -la

nothing in htmlgit?

cd ../

rmdir htmlgit

Once installed and up and running, if an update becomes available and one wants to apply it.

First, backup code directory and get a SQL dump of database.   Take the time to do this ... you will not regret taking the time to do it should you need it. ;)

cd /var/www/html/

git pull

That's it!

To update the DB:

php admin/cli/maintenance.php --enable

php admin/cli/upgrade.php --non-interactive

php admin/cli/maintenance.php --disable

chown apache:apache * -R

Now hit with browser.

To upgrade from a 3.2 to 3.3

cd /var/www/html/

git branch --track MOODLE_33_STABLE origin/MOODLE_33_STABLE
git checkout MOODLE_33_STABLE

check the version.php file:

fgrep '$release' version.php

Should show 3.3.x

To finish the upgrade the same commands as above.

php admin/cli/maintenance.php --enable

php admin/cli/upgrade.php --non-interactive

php admin/cli/maintenance.php --disable

chown apache:apache * -R

Uhhhh ... don't forget, there are some DB information/changes one needs to research before pulling trigger on upgrade from 3.2 to 3.3

'spirit of sharing', Ken


In reply to Ken Task

Re: Moodle not recognizing git pull update

by Natassia Stelmaszek -
Noodle is being king served out of /var/WWW/HTML/moodle.  (Irregular case

due to phone's autocorrect) I'll look at the rest more closely when I get

back to a real computer. Natassia



On Jun 2, 2017 7:01 PM, "Ken Task (via Moodle.org)" <noreply@moodle.org>
In reply to Ken Task

Re: Moodle not recognizing git pull update

by Natassia Stelmaszek -

Ken,

Thank you.  Mistakes are learning opportunities and I have learned quite a bit over the last week.

Now I see that the git clone command needs to create a new directory in order to set up the framework that future git commands will use.  Once the files are in the new directory they can be copied to another directory and then moving the hidden files moves that framework as well.

I continue to be amazed at how many mistakes that I can make and still have Moodle continue to operate!

One note just in case others follow your excellent directions.  Since the bulk of the files in the htmlgit directory were copied rather than moved, the directory will not be empty.  The rmdir command will fail unless you delete the files first.

My Beta site is now at 3.3, I had already taken the steps to use utf8mb4.  Hopefully I won't make the same mistakes while updating my Production system.

Thanks again for devoting so much of your time to answering forum question.

Natassia