fixing changelog stuff, need to update changelog

This commit is contained in:
Ralf Becker 2010-09-29 12:53:08 +00:00
parent 36a7d8199e
commit 97611bbc3a

View File

@ -190,9 +190,14 @@ function do_editsvnchangelog()
{ {
die("\nChangelog must not be empty --> aborting\n\n"); die("\nChangelog must not be empty --> aborting\n\n");
} }
file_put_contents(__DIR__.'/debian.changelog', $config['changelog']); // commit changelog
$cmd = $svn." commit -m 'Changelog for $config[version].$config[packaging]' ".__DIR__.'/debian.changelog'; $changelog = __DIR__.'/debian.changes';
run_cmd($cmd); if (file_exists($changelog))
{
file_put_contents($changelog, update_changelog(file_get_contents($changelog)));
$cmd = $svn." commit -m 'Changelog for $config[version].$config[packaging]' ".$changelog;
run_cmd($cmd);
}
} }
/** /**
@ -349,11 +354,7 @@ function do_obs()
} }
if (basename($path) == 'debian.changes' && strpos($content,$config['version'].'.'.$config['packaging']) === false) if (basename($path) == 'debian.changes' && strpos($content,$config['version'].'.'.$config['packaging']) === false)
{ {
list($new_header) = explode("\n",$content); $content = update_changelog($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;
} }
if (!empty($config['changelog']) && substr($path,-5) == '.spec' && if (!empty($config['changelog']) && substr($path,-5) == '.spec' &&
($pos_changelog = strpos($content,'%changelog')) !== false) ($pos_changelog = strpos($content,'%changelog')) !== false)
@ -379,6 +380,25 @@ function do_obs()
} }
} }
/**
* Update content of debian changelog file with new content from $config[changelog]
*
* @param string $content existing changelog content
* @return string updated changelog content
*/
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;
}
/** /**
* Sign sha1sum file * Sign sha1sum file
*/ */