CVS-Metrics
view release on metacpan or search on metacpan
bin/cvs_current view on Meta::CPAN
}
print "Branch : @branchs\n";
if ($flg_head) {
push @tags, 'HEAD';
$cvs_log->insertHead();
}
my $tag_from = $tags[-2];
my $tag_to = $tags[-1];
my @html = ();
push @html, GenerateHTML($cvs_log, \@tags, $title, '.', $tag_from, $tag_to, $flg_css, $start_date, $output);
for my $path (@dirs) {
push @html, GenerateHTML($cvs_log, \@tags, $title, $path, $tag_from, $tag_to, $flg_css, $start_date, $output);
}
my @html2 = ();
for my $branch (@branchs) {
push @html2, GenerateBranchHTML($cvs_log, $branch, $title, '.', $flg_css, $output);
}
GenerateSummary($title, $flg_css, \@html, \@html2, $output);
}
sub FindCvs {
my $cvs;
if ($^O eq 'MSWin32') {
eval 'use File::Which';
$cvs = which('cvs');
unless (defined $cvs) {
eval 'use Win32::TieRegistry(Delimiter => "/")';
my $cvs_setting;
my $hkey = 'HKEY_CURRENT_USER/Software/WinCvs/wincvs/CVS settings';
eval '$cvs_setting = $Registry->{$hkey}';
$cvs = $cvs_setting->{'/P_WhichCvs'};
if (defined $cvs) {
$cvs =~ s/[\000\001]//g;
$cvs =~ s/wincvs\.exe\@$//;
if ( -e "${cvs}CVSNT\\\\cvs.exe") {
$cvs .= "CVSNT\\\\cvs.exe";
}
else {
$cvs .= 'cvs.exe';
}
}
}
die "cvs not found !\n" unless (defined $cvs);
warn "Using CVS : $cvs\n";
return q{"} . $cvs . q{"};
}
else {
return 'cvs';
}
}
#######################################################################
sub GenerateHTML {
my ($cvs_log, $tags, $title, $path, $tag_from, $tag_to, $flg_css, $start_date, $output) = @_;
my $html = q{
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />
<meta name='generator' content='<TMPL_VAR NAME=generator>' />
<meta name='date' content='<TMPL_VAR NAME=date>' />
<title>cvs_current <!-- TMPL_VAR NAME=title --></title>
<!-- TMPL_IF NAME=css -->
<link href='cvs_current.css' rel='stylesheet' type='text/css'/>
<!-- TMPL_ELSE -->
<style type='text/css'>
<!-- TMPL_VAR NAME=style -->
</style>
<!-- /TMPL_IF -->
</head>
<body>
<h1>Evolution Report</h1>
<h1><!-- TMPL_VAR NAME=title --></h1>
<hr />
<h2>Activity</h2>
<img src='<TMPL_VAR NAME=a_img>' />
<h2>Context</h2>
<table class='layout'>
<tr>
<td valign='top'><img src='<TMPL_VAR NAME=e_img>' /></td>
<td valign='top'>
<table border='1' cellpadding='5'>
<tr>
<th>Tag</th>
<th>Date</th>
</tr>
<!-- TMPL_LOOP NAME=timed_tag -->
<tr>
<td><!-- TMPL_VAR NAME=tag --></td>
<td><!-- TMPL_VAR NAME=timed --></td>
</tr>
<!-- /TMPL_LOOP -->
</table>
</td>
</tr>
</table>
<hr />
<h2>Evolution Report Summary</h2>
<table border='1' cellpadding='5'>
<tr>
<th width='40%'>Directories</th>
<th width='20%'>Added files</th>
<th width='20%'>Modified files</th>
<th width='20%'>Deleted files</th>
</tr>
<!-- TMPL_LOOP NAME=summary -->
<tr>
<td><a href='#<TMPL_VAR NAME=dir>'><!-- TMPL_VAR NAME=dir --></a></td>
<td><!-- TMPL_VAR NAME=added --></td>
<td><!-- TMPL_VAR NAME=modified --></td>
<td><!-- TMPL_VAR NAME=deleted --></td>
</tr>
<!-- /TMPL_LOOP -->
<tr class='total'>
<td>TOTAL</td>
<td><!-- TMPL_VAR NAME=total_added --></td>
bin/cvs_current view on Meta::CPAN
$message =~ s/</</g;
$message =~ s/>/>/g;
$message =~ s/\n/<br \/>/g;
push @comments, {
rowspan => $rowspan2,
comment => $message,
files => \@files,
};
}
push @dirs, {
rowspan => $rowspan1,
dir => $dirname,
comments => \@comments,
}
}
$template->param(
css => $flg_css,
style => $style,
generator => $generator,
date => $now,
title => $title_full,
e_img => $e_img,
a_img => $a_img,
timed_tag => \@timed_tag,
summary => \@summary,
total_added => $total_added,
total_modified => $total_modified,
total_deleted => $total_deleted,
dirs => \@dirs,
);
my $basename = "${title_full}.html";
$basename =~ s/[ \/]/_/g;
$filename = (defined $output) ? $output . '/' . $basename : $basename;
open my $OUT, '>', $filename
or die "can't open $filename ($!)\n";
print $OUT $template->output();
close $OUT;
if ($flg_css) {
my $stylesheet = 'cvs_current.css';
$stylesheet = $output . "/" . $stylesheet
if ($output);
unless (-e $stylesheet) {
open my $OUT, '>', $stylesheet
or die "can't open $stylesheet ($!)\n";
print $OUT $style;
close $OUT;
}
}
return $basename;
}
sub GenerateBranchHTML {
my ($cvs_log, $branch, $title, $path, $flg_css, $output) = @_;
my $html = q{
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />
<meta name='generator' content='<TMPL_VAR NAME=generator>' />
<meta name='date' content='<TMPL_VAR NAME=date>' />
<title>cvs_current <!-- TMPL_VAR NAME=title --></title>
<!-- TMPL_IF NAME=css -->
<link href='cvs_current.css' rel='stylesheet' type='text/css'/>
<!-- TMPL_ELSE -->
<style type='text/css'>
<!-- TMPL_VAR NAME=style -->
</style>
<!-- /TMPL_IF -->
</head>
<body>
<h1>Branch Report</h1>
<h1><!-- TMPL_VAR NAME=title --></h1>
<hr />
<h2>Branch Report Summary</h2>
<table border='1' cellpadding='5'>
<tr>
<th>Directories</th>
<th># files</th>
</tr>
<!-- TMPL_LOOP NAME=summary -->
<tr>
<td><a href='#<TMPL_VAR NAME=dir>'><!-- TMPL_VAR NAME=dir --></a></td>
<td><!-- TMPL_VAR NAME=nb --></td>
</tr>
<!-- /TMPL_LOOP -->
<tr class='total'>
<td>TOTAL</td>
<td><!-- TMPL_VAR NAME=total --></td>
</tr>
</table>
<hr />
<h2>Branch Evolution Report</h2>
<table border='1' cellpadding='5'>
<tr>
<th width='20%'>Directories</th>
<th width='40%'>Messages</th>
<th width='30%'>File Descriptions</th>
<th width='10%'>Actions</th>
</tr>
<!-- TMPL_LOOP NAME=dirs --><tr>
<td valign='top' rowspan='<TMPL_VAR NAME=rowspan>'><a id='<TMPL_VAR NAME=dir>'
name='<TMPL_VAR NAME=dir>' /><!-- TMPL_VAR NAME=dir --></td>
<!-- TMPL_LOOP NAME=comments -->
<!-- TMPL_UNLESS NAME=__FIRST__ --><tr><!-- /TMPL_UNLESS -->
<td valign='top' rowspan='<TMPL_VAR NAME=rowspan>'><!-- TMPL_VAR NAME=comment --></td>
<!-- TMPL_LOOP NAME=files -->
<!-- TMPL_UNLESS NAME=__FIRST__ --><tr><!-- /TMPL_UNLESS -->
<td><span class='filename'><!-- TMPL_VAR NAME=filename --></span>
<span class='revision'><!-- TMPL_VAR NAME=revision --></span><br />
<!-- TMPL_LOOP NAME=tags -->
<span class='tag'><!-- TMPL_VAR NAME=tag --></span><br />
<!-- /TMPL_LOOP -->
<span class='author'><!-- TMPL_VAR NAME=author --></span>
<span class='date'><!-- TMPL_VAR NAME=date --></span></td>
<td><!-- TMPL_VAR NAME=action --></td>
bin/cvs_current view on Meta::CPAN
}
else {
$action = "<span class='modified'>MODIFIED</span>";
}
}
push @files, {
filename => basename($file->{filename}),
revision => $file->{revision},
date => $file->{date},
author => $file->{author},
action => $action,
tags => \@tags,
};
$rowspan1 ++;
$rowspan2 ++;
}
$message =~ s/&/&/g;
$message =~ s/</</g;
$message =~ s/>/>/g;
$message =~ s/\n/<br \/>/g;
push @comments, {
rowspan => $rowspan2,
comment => $message,
files => \@files,
};
}
push @dirs, {
rowspan => $rowspan1,
dir => $dirname,
comments => \@comments,
}
}
$template->param(
css => $flg_css,
style => $style,
generator => $generator,
date => $now,
title => $title_full,
summary => \@summary,
total => $total,
dirs => \@dirs,
);
my $basename = "${title_full}.html";
$basename =~ s/[ \/]/_/g;
my $filename = (defined $output) ? $output . '/' . $basename : $basename;
open my $OUT, '>', $filename
or die "can't open $filename ($!)\n";
print $OUT $template->output();
close $OUT;
return $basename;
}
sub GenerateSummary {
my ($title, $flg_css, $r_html, $r_html2, $output) = @_;
my $html = q{
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />
<meta name='generator' content='<TMPL_VAR NAME=generator>' />
<meta name='date' content='<TMPL_VAR NAME=date>' />
<title>cvs_current <!-- TMPL_VAR NAME=title --></title>
<!-- TMPL_IF NAME=css -->
<link href='cvs_current.css' rel='stylesheet' type='text/css'/>
<!-- TMPL_ELSE -->
<style type='text/css'>
<!-- TMPL_VAR NAME=style -->
</style>
<!-- /TMPL_IF -->
</head>
<body>
<h1><!-- TMPL_VAR NAME=title --></h1>
<hr />
<h2>Reports Index</h2>
<ul>
<!-- TMPL_LOOP NAME=rpts -->
<li><a href='<TMPL_VAR NAME=href>'><!-- TMPL_VAR NAME=href --></a></li>
<!-- /TMPL_LOOP -->
</ul>
<!-- TMPL_IF NAME=branch -->
<h2>Branch Reports Index</h2>
<ul>
<!-- TMPL_LOOP NAME=rpts2 -->
<li><a href='<TMPL_VAR NAME=href>'><!-- TMPL_VAR NAME=href --></a></li>
<!-- /TMPL_LOOP -->
</ul>
<!-- /TMPL_IF -->
<hr />
<cite>Generated by cvs_current (<!-- TMPL_VAR NAME=date -->)</cite>
</body>
</html>
};
my $style = q{
body { background-color: #FFFFCC }
h1 { text-align: center }
h2 { color: red }
};
my $template = HTML::Template->new(
loop_context_vars => 1,
scalarref => \$html,
);
die "can't create template ($!).\n"
unless (defined $template);
my $now = localtime();
my $generator = 'cvs_current ' . $CVS::Metrics::VERSION . ' (Perl ' . $] . ')';
my @rpts = ();
foreach (@{$r_html}) {
push @rpts, {
href => $_,
}
}
my @rpts2 = ();
( run in 0.571 second using v1.01-cache-2.11-cpan-39bf76dae61 )