Moodle versions in git

All versions of Moodle are appropriately tagged in the Moodle git repository (git://git.moodle.org/moodle.git) so you can use the following to show the commits that relate to each version. Just a note too that major versions are branched using the convention MOODLE_XX_STABLE where XX is the version e.g. MOODLE_36_STABLE for Moodle 3.6.

git show-ref --tags

This gives you something like this:

...
30e069a061296bef321b31b791a4366a953cae23 refs/tags/v3.6.1
008baea92aa20ee7ff619d37cc6568b076cda00c refs/tags/v3.6.2
ec902921430745139548095e45380ed017acd770 refs/tags/v3.6.3

Here you can see that the v3.6.1 tag has the commit hash 30e069a061296bef321b31b791a4366a953cae23 (the tag is just an alias for that hash).

Use the version.php file to find out the details of that version using the tag as a shortcut e.g.

git show v3.6.1:version.php

Sometimes you want to know what files changed between versions, you can use git diff with the --stat option for that:

git diff v3.6.2 v3.6.3 --stat

If you use a diff/merge tool (e.g. Araxis Merge) you can use the --dir-diff to get a full directory comparison of changes between tags as well. Very handy.

git difftool --dir-diff v3.6.1 v3.6.2

One other useful thing is to look at the log between two tags like so:

git log --oneline v3.6.1..v3.6.2

Handy to see what Moodle fixes were added between tags (MDL-) which you can check against the Moodle Tracker

 

Finding specific Moodle versions in the Moodle Git Repository

The key to working with the Moodle git repository (https://docs.moodle.org/31/en/Git_for_Administrators) is to look at changes to the version.php file in the main moodle directory which tells you the moodle version.

You can use the whatchanged git command to get a summary of all changes and tags.

git whatchanged -p version.php

But more than likely if you are upgrading or patching you want to find a specific Moodle version. For example, I want to find the commit that relates to “Moodle release 3.1.2” which has the following in the version variable:

2016052302.00

To find that use whatchanged to search for that value like so:

git whatchanged -p -S2016052302.00 version.php

This gets you the results that revolve around that version change, e.g. perhaps you want the change from version v3.1.1 to v3.1.2.
Once you have the commit hash e.g. f851201 you can then checkout that hash for example to see that specific version. Make sure you confirm you have what you need by looking at version.php first.

git checkout f851201-B moodle
 

Themes and Page Layouts

The types of page layouts – which determine how your moodle page is rendered via:

$PAGE->set_pagelayout('layout');

These are defined in the base theme (and can be extended by custom themes): Have a look in theme/base/config.php in the $THEME->layouts array for options.

 

Convert a Moodle URL object to string

There’s a method in the moodle_url class in lib/weblib.php called __toString which will convert a Moodle URL object back to a string if you just need the URL string itself.

$PAGE->url->__toString()