parameter to copy changelog automatically eg. to sf.net

This commit is contained in:
Ralf Becker 2011-02-16 10:06:48 +00:00
parent 75ec08885a
commit 56b933e06d

View File

@ -42,8 +42,9 @@ $config = array(
'editor' => '/usr/bin/vi',
'svntag' => 'tags/$version.$packaging', // eg. '$version.$packaging'
'release' => 'ralfbecker,egroupware@frs.sourceforge.net:/home/frs/project/e/eg/egroupware/eGroupware-$version/eGroupware-$version.$packaging/',
'copychangelog' => 'ralfbecker,egroupware@frs.sourceforge.net:/home/frs/project/e/eg/egroupware/README',
'skip' => array(),
'run' => array('editsvnchangelog','svntag','checkout','copy','virusscan','create','sign','obs','release')
'run' => array('editsvnchangelog','svntag','checkout','copy','virusscan','create','sign','obs','release','copychangelog')
);
// process config from command line
@ -85,10 +86,11 @@ while(($arg = array_shift($argv)))
case 'svntag':
case 'release':
case 'copychangelog':
$config[$name] = $value;
array_unshift($config['run'],$name);
break;
case 'editsvnchangelog':
$config[$name] = $value ? $value : true;
if (!in_array('editsvnchangelog',$config['run']))
@ -145,6 +147,25 @@ function do_release()
passthru($cmd);
}
/**
* Copy changelog by rsync'ing it to a distribution / download directory
*/
function do_copychangelog()
{
global $config,$verbose;
$changelog = __DIR__.'/debian.changes';
$target = $config['copychangelog'];
if (strpos($target,'$') !== false) // allow to use config vars like $svnbranch in module
{
$translate = array();
foreach($config as $name => $value) $translate['$'.$name] = $value;
$target = strtr($target,$translate);
}
$cmd = $config['rsync'].' '.$changelog.' '.$target;
passthru($cmd);
}
/**
* Query changelog from svn and let user edit it
*/
@ -202,7 +223,7 @@ function do_editsvnchangelog()
/**
* Read changelog for given branch from (last) tag or given revision from svn
*
*
* @param string $branch_url='svn+ssh://svn@svn.stylite.de/egroupware/branches/Stylite-EPL-10.1'
* @param string $log_pattern=null a preg regular expression or start of line a log message must match, to be returned
* if regular perl regular expression given only first expression in brackets \\1 is used,
@ -214,7 +235,7 @@ function get_changelog_from_svn($branch_url,$log_pattern=null,&$revision,$prefix
{
//echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n";
global $config,$verbose,$svn;
if (is_null($revision))
{
list($tags_url,$branch) = explode('/branches/',$branch_url);
@ -237,7 +258,7 @@ function get_changelog_from_svn($branch_url,$log_pattern=null,&$revision,$prefix
run_cmd($cmd,$output);
$verbose = $v;
array_shift($output); // remove the command
$xml = simplexml_load_string($output=implode("\n",$output));
$message = '';
$pattern_len = strlen($log_pattern);
@ -267,7 +288,7 @@ function get_changelog_from_svn($branch_url,$log_pattern=null,&$revision,$prefix
/**
* Get revision of last svn tag matching a given pattern in the log message
*
*
* @param string $tags_url
* @param string $pattern which has to be contained in the log message (NOT the tag itself)
* or (perl) regular expression against which log message is matched
@ -277,8 +298,8 @@ function get_changelog_from_svn($branch_url,$log_pattern=null,&$revision,$prefix
function get_last_svn_tag($tags_url,$pattern,&$matches=null)
{
global $config,$verbose,$svn;
$cmd = $svn.' log --xml --limit 10 '.escapeshellarg($tags_url);
$cmd = $svn.' log --xml --limit 20 '.escapeshellarg($tags_url);
if (($v = $verbose))
{
echo "Querying SVN for last tags\n$cmd\n";
@ -288,7 +309,7 @@ function get_last_svn_tag($tags_url,$pattern,&$matches=null)
run_cmd($cmd,$output);
$verbose = $v;
array_shift($output); // remove the command
$xml = simplexml_load_string($output=implode("\n",$output));
foreach($xml as $log)
{
@ -337,7 +358,7 @@ function do_obs()
++$n;
}
// updating dsc, spec and changelog files
if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec' ||
if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec' ||
!empty($config['changelog']) && basename($path) == 'debian.changes')
{
$content = $content_was = file_get_contents($path);
@ -389,13 +410,13 @@ function do_obs()
function update_changelog($content)
{
global $config,$verbose;
list($new_header) = explode("\n",$content);
$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)',$new_header);
if (substr($config['changelog'],0,2) != ' ') $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog']));
$content = $new_header."\n\n".$config['changelog'].
"\n\n -- ".$config['changelog_packager'].' '.date('r')."\n\n".$content;
return $content;
}
@ -563,7 +584,7 @@ function do_checkout()
throw new Exception("svn checkout directory '{$config['svndir']} exists and is NO directory or NOT writable!");
}
chdir($config['svndir']);
// do we use a just created tag --> list of taged modules
if ($config['svntag'] && isset($config['modules']))
{
@ -639,7 +660,7 @@ function do_checkout()
/**
* Get module name per svn repro
*
*
* @return array with $repro_url => array(module1, ..., moduleN) pairs
*/
function get_modules_per_repro()