Best practice forum (Archived)

general developer question - version.php and git branches

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

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?

? ?
Re: general developer question - version.php and git branches
di ? ? - Sunday, 19 February 2012, 11:32
 

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.

L'intervento è stato rimosso
Sunday, 19 February 2012, 13:12
Il contenuto di questo intervento è stato rimosso, non è più possibile visualizzarlo.
Simon Coggins
Re: general developer question - version.php and git branches
di Simon Coggins - Wednesday, 22 February 2012, 16:12
Gruppo 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