Best practice forum (Archived)

general developer question - version.php and git branches

 
Swtizerland 2004
general developer question - version.php and git branches
by Russell England - Friday, 17 February 2012, 6:12 AM
 

Bit of a general developer question.

I'm often switching between git branches on Totara projects, but this means the versions for the plugins/modules often get out of synch with the database.

Say I'm working on plugin A in git branch A which is version 20120217. The database now has 20120217 as the version for plugin A.

I now need to work on plugin B in branch B. So I switch git branches, but the version in the plugin A code will probably be an earlier version to the one in the database, eg 20120214.

So I get an error message saying

"Version mismatch: plugin A can't downgrade 20120217 -> 20120214 !"

So to work around it, I look for the version in mdl_config and change it to the earlier version.

update mdl_config
set value='20120217'
where name = 'local_plugina_version'

I just wondered what other developers do to get around this?

Dan Marsden
Re: general developer question - version.php and git branches
by Dan Marsden - Sunday, 19 February 2012, 11:32 AM
 

I use a different db or a different prefix for each branch by using something like this in my config.php (stole this from another dev at some point)

$branch = `/usr/bin/git branch | grep '^\*' | awk ' { print $2 } ' | tr -d '\n'`;
$branchbits = explode("-", $branch);

then use stuff like:

$CFG->dbname    = $branchbits[1];
$CFG->prefix    = $branchbits[0].'_';

hope that's useful.

This forum post has been removed
Sunday, 19 February 2012, 1:12 PM
The content of this forum post has been removed and can no longer be accessed.
Simon Coggins
Re: general developer question - version.php and git branches
by Simon Coggins - Wednesday, 22 February 2012, 4:12 PM
Group Totara

Similar to alastair, I have different configs for different release branches and have a script to quickly switch between them.

I used to use an automatic script that used a git hook to switch to a db of the same name as the branch but it got annoying having to install new dbs all the time.

Simon