Info
Content

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. 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).

The key to working with the Moodle git repository is the version.php file. This file is changed on every major commit, so you can use it to track down a specific moodle version in the repository (use this in conjunction with branches and version tags).

git show v3.6.1:version.php

To see what’s changed on this file including the file changes themselves use:

git whatchanged -p version.php

This is handy, but chances are you are searching for a specific version. Eg. say I want version 2012062503.02. How do I track down the commit(s) that relate to that version? Use the command above but add the -S search parameter:

git whatchanged -p -S2012062503.02 version.php

This gives you the commit details (including the hash) you need. If you get multiple results, you probably want the latest commit.

Once you have the correct commit, use git checkout with the branch option to make/set your branch. E.g.

git checkout 5f1d8f2 -B moodle

Now my moodle git repository is on the exact commit I need. Very useful for comparing a code base to a vanilla Moodle to find any customisations.

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.

No Comments
Back to top