added a single file CLOC support
This commit is contained in:
parent
417e35c629
commit
b690831cb0
@ -107,5 +107,6 @@ LICENSE
|
|||||||
jQuery JavaScript Library v1.4.2 See http://jquery.org/license
|
jQuery JavaScript Library v1.4.2 See http://jquery.org/license
|
||||||
jQuery UI 1.8 MIT or GPL
|
jQuery UI 1.8 MIT or GPL
|
||||||
PHPGraphLib MIT
|
PHPGraphLib MIT
|
||||||
|
CLOC 1.62 GPL
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ License: GPL
|
|||||||
Group: Applications/Utilities
|
Group: Applications/Utilities
|
||||||
Source0: %{name}-%{version}.tar.gz
|
Source0: %{name}-%{version}.tar.gz
|
||||||
|
|
||||||
Requires: httpd php php-ldap php-mysql php-gd subversion subversion-perl mod_dav_svn mod_perl perl-LDAP perl-Config-Simple perl-URI perl-DBI perl-Digest-SHA1
|
Requires: httpd php php-ldap php-mysql php-gd subversion subversion-perl mod_dav_svn mod_perl perl perl-LDAP perl-Config-Simple perl-URI perl-DBI perl-Digest-SHA1
|
||||||
|
|
||||||
#BuildRequires:
|
#BuildRequires:
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-root
|
BuildRoot: %{_tmppath}/%{name}-%{version}-root
|
||||||
@ -52,6 +52,7 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
/etc/codepot/post-commit
|
/etc/codepot/post-commit
|
||||||
/etc/codepot/pre-revprop-change
|
/etc/codepot/pre-revprop-change
|
||||||
/etc/codepot/post-revprop-change
|
/etc/codepot/post-revprop-change
|
||||||
|
/etc/codepot/cloc.pl
|
||||||
/etc/codepot/perl/Codepot/AccessHandler.pm
|
/etc/codepot/perl/Codepot/AccessHandler.pm
|
||||||
/etc/codepot/perl/Codepot/AuthenHandler.pm
|
/etc/codepot/perl/Codepot/AuthenHandler.pm
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
cfgdir=$(CFGDIR)
|
cfgdir=$(CFGDIR)
|
||||||
cfg_DATA = codepot.ini codepot.mysql codepot.a2ldap codepot.httpd
|
cfg_DATA = codepot.ini codepot.mysql codepot.a2ldap codepot.httpd
|
||||||
cfg_SCRIPTS = start-commit pre-commit post-commit pre-revprop-change post-revprop-change
|
cfg_SCRIPTS = start-commit pre-commit post-commit pre-revprop-change post-revprop-change cloc.pl
|
||||||
|
|
||||||
perldir=$(CFGDIR)/perl/Codepot
|
perldir=$(CFGDIR)/perl/Codepot
|
||||||
perl_SCRIPTS=perl/Codepot/AccessHandler.pm perl/Codepot/AuthenHandler.pm
|
perl_SCRIPTS=perl/Codepot/AccessHandler.pm perl/Codepot/AuthenHandler.pm
|
||||||
|
@ -151,7 +151,7 @@ sysconfdir = @sysconfdir@
|
|||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
wwwdir = @wwwdir@
|
wwwdir = @wwwdir@
|
||||||
cfg_DATA = codepot.ini codepot.mysql codepot.a2ldap codepot.httpd
|
cfg_DATA = codepot.ini codepot.mysql codepot.a2ldap codepot.httpd
|
||||||
cfg_SCRIPTS = start-commit pre-commit post-commit pre-revprop-change post-revprop-change
|
cfg_SCRIPTS = start-commit pre-commit post-commit pre-revprop-change post-revprop-change cloc.pl
|
||||||
perldir = $(CFGDIR)/perl/Codepot
|
perldir = $(CFGDIR)/perl/Codepot
|
||||||
perl_SCRIPTS = perl/Codepot/AccessHandler.pm perl/Codepot/AuthenHandler.pm
|
perl_SCRIPTS = perl/Codepot/AccessHandler.pm perl/Codepot/AuthenHandler.pm
|
||||||
EXTRA_DIST = $(cfg_DATA) $(cfg_SCRIPTS) $(perl_SCRIPTS)
|
EXTRA_DIST = $(cfg_DATA) $(cfg_SCRIPTS) $(perl_SCRIPTS)
|
||||||
|
9744
codepot/etc/cloc.pl
Executable file
9744
codepot/etc/cloc.pl
Executable file
File diff suppressed because it is too large
Load Diff
@ -219,3 +219,10 @@ svn_min_commit_message_length = "0"
|
|||||||
; Leave this empty for the default footer message
|
; Leave this empty for the default footer message
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
footer = ""
|
footer = ""
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; CLOC command
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; Full path to the CLOC command
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
cloc_command_path = "@CFGDIR@/cloc.pl"
|
||||||
|
@ -635,7 +635,7 @@ class Code extends Controller
|
|||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
function graph ($type = '', $projectid = '', $path = '')
|
function graph ($type = '', $projectid = '', $path = '', $rev = SVN_REVISION_HEAD)
|
||||||
{
|
{
|
||||||
$this->load->model ('ProjectModel', 'projects');
|
$this->load->model ('ProjectModel', 'projects');
|
||||||
|
|
||||||
@ -659,12 +659,100 @@ class Code extends Controller
|
|||||||
if ($path == '.') $path = ''; /* treat a period specially */
|
if ($path == '.') $path = ''; /* treat a period specially */
|
||||||
$path = $this->_normalize_path ($path);
|
$path = $this->_normalize_path ($path);
|
||||||
|
|
||||||
|
|
||||||
|
if ($type == 'cloc-file')
|
||||||
|
{
|
||||||
|
// number of lines in a single file
|
||||||
|
|
||||||
|
$file = $this->subversion->getFile ($projectid, $path, $rev);
|
||||||
|
if ($file === FALSE)
|
||||||
|
{
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($file['type'] != 'file')
|
||||||
|
{
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tfname = @tempnam(__FILE__, 'xxx');
|
||||||
|
if ($tfname === FALSE)
|
||||||
|
{
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tfname = $tfname . '.' . pathinfo ($file['name'], PATHINFO_EXTENSION);
|
||||||
|
@file_put_contents ($tfname, $file['content']);
|
||||||
|
|
||||||
|
$cloc_cmd = sprintf ('%s --quiet --csv --csv-delimiter=":" %s', CODEPOT_CLOC_COMMAND_PATH, $tfname);
|
||||||
|
$cloc = @popen ($cloc_cmd, 'r');
|
||||||
|
if ($cloc === FALSE)
|
||||||
|
{
|
||||||
|
@unlink ($tfname);
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$line_count = 0;
|
||||||
|
$counter = FALSE;
|
||||||
|
while (!feof($cloc))
|
||||||
|
{
|
||||||
|
$line = @fgets ($cloc);
|
||||||
|
if ($line_count == 2)
|
||||||
|
{
|
||||||
|
$counter = explode (':', $line);
|
||||||
|
}
|
||||||
|
$line_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
@pclose ($cloc);
|
||||||
|
@unlink ($tfname);
|
||||||
|
|
||||||
|
if ($counter === FALSE)
|
||||||
|
{
|
||||||
|
$stats = array (
|
||||||
|
'no-data' => 0
|
||||||
|
);
|
||||||
|
$title = $file['name'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$stats = array (
|
||||||
|
'blank' => (integer)$counter[2],
|
||||||
|
'comment' => (integer)$counter[3],
|
||||||
|
'code' => (integer)$counter[4],
|
||||||
|
'total' => (integer)$counter[2] + (integer)$counter[3] + (integer)$counter[4]
|
||||||
|
);
|
||||||
|
|
||||||
|
$title = $file['name'] . ' (' . $counter[1] . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->load->library ('PHPGraphLib', array ('width' => 280, 'height' => 200), 'graph');
|
||||||
|
$this->graph->addData($stats);
|
||||||
|
$this->graph->setTitle($title);
|
||||||
|
$this->graph->setDataPoints(TRUE);
|
||||||
|
$this->graph->setDataValues(TRUE);
|
||||||
|
$this->graph->setBars(TRUE);
|
||||||
|
$this->graph->setXValuesHorizontal(TRUE);
|
||||||
|
$this->graph->setYValues (FALSE);
|
||||||
|
$this->graph->createGraph();
|
||||||
|
}
|
||||||
|
else if ($type == 'commit-share-by-users')
|
||||||
|
{
|
||||||
|
// revision is ignored
|
||||||
$file = $this->subversion->getHistory ($projectid, $path, SVN_REVISION_HEAD);
|
$file = $this->subversion->getHistory ($projectid, $path, SVN_REVISION_HEAD);
|
||||||
|
if ($file === FALSE)
|
||||||
|
{
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$history = $file['history'];
|
$history = $file['history'];
|
||||||
$history_count = count($history);
|
$history_count = count($history);
|
||||||
|
|
||||||
if ($type == 'commit-share-by-users')
|
|
||||||
{
|
|
||||||
$stats = array();
|
$stats = array();
|
||||||
for ($i = 0; $i < $history_count; $i++)
|
for ($i = 0; $i < $history_count; $i++)
|
||||||
{
|
{
|
||||||
@ -679,13 +767,24 @@ class Code extends Controller
|
|||||||
|
|
||||||
$this->load->library ('PHPGraphLibPie', array ('width' => 400, 'height' => 300), 'graph');
|
$this->load->library ('PHPGraphLibPie', array ('width' => 400, 'height' => 300), 'graph');
|
||||||
$this->graph->addData($stats);
|
$this->graph->addData($stats);
|
||||||
$this->graph->setTitle("Commit share by users");
|
$this->graph->setTitle('Commit share by users');
|
||||||
$this->graph->setLabelTextColor('50,50,50');
|
$this->graph->setLabelTextColor('50,50,50');
|
||||||
$this->graph->setLegendTextColor('50,50,50');
|
$this->graph->setLegendTextColor('50,50,50');
|
||||||
$this->graph->createGraph();
|
$this->graph->createGraph();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// revision is ignored
|
||||||
|
$file = $this->subversion->getHistory ($projectid, $path, SVN_REVISION_HEAD);
|
||||||
|
if ($file === FALSE)
|
||||||
|
{
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$history = $file['history'];
|
||||||
|
$history_count = count($history);
|
||||||
|
|
||||||
$stats = array();
|
$stats = array();
|
||||||
for ($i = 0; $i < $history_count; $i++)
|
for ($i = 0; $i < $history_count; $i++)
|
||||||
{
|
{
|
||||||
@ -700,7 +799,7 @@ class Code extends Controller
|
|||||||
|
|
||||||
$this->load->library ('PHPGraphLib', array ('width' => 400, 'height' => 300), 'graph');
|
$this->load->library ('PHPGraphLib', array ('width' => 400, 'height' => 300), 'graph');
|
||||||
$this->graph->addData($stats);
|
$this->graph->addData($stats);
|
||||||
$this->graph->setTitle("Commits by users");
|
$this->graph->setTitle('Commits by users');
|
||||||
$this->graph->setDataPoints(TRUE);
|
$this->graph->setDataPoints(TRUE);
|
||||||
$this->graph->setDataValues(TRUE);
|
$this->graph->setDataValues(TRUE);
|
||||||
//$this->graph->setLine(TRUE);
|
//$this->graph->setLine(TRUE);
|
||||||
|
@ -261,6 +261,14 @@ if (array_key_exists('properties', $file) && count($file['properties']) > 0)
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<div class="title">CLOC</div>
|
||||||
|
<?php
|
||||||
|
/* TODO: show this if it's enabled in the user settings */
|
||||||
|
$graph_url = codepot_merge_path (site_url(), "/code/graph/cloc-file/{$project->id}/{$xpar}{$revreq}");
|
||||||
|
print "<img src='{$graph_url}' />";
|
||||||
|
?>
|
||||||
|
|
||||||
</div> <!-- code_file_mainarea_result_info -->
|
</div> <!-- code_file_mainarea_result_info -->
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +80,8 @@ function load_ini ($file)
|
|||||||
array ('signin_for_code_search', 'boolean', TRUE),
|
array ('signin_for_code_search', 'boolean', TRUE),
|
||||||
array ('svn_for_members_only', 'boolean', FALSE),
|
array ('svn_for_members_only', 'boolean', FALSE),
|
||||||
|
|
||||||
array ('footer', 'string', '')
|
array ('footer', 'string', ''),
|
||||||
|
array ('cloc_command_path', 'string', CODEPOT_CFG_DIR.'/cloc.pl')
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($xcfgs as $x)
|
foreach ($xcfgs as $x)
|
||||||
|
@ -10,8 +10,13 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------
|
||||||
|
* file show view
|
||||||
|
*-----------------------------------------------*/
|
||||||
|
|
||||||
#file_show_mainarea_result {
|
#file_show_mainarea_result {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
min-height: 13em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#file_show_mainarea_result_info {
|
#file_show_mainarea_result_info {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
|
/*---------------------------------------------
|
||||||
|
* wiki show
|
||||||
|
*---------------------------------------------*/
|
||||||
|
|
||||||
#wiki_show_mainarea_result {
|
#wiki_show_mainarea_result {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
min-height: 13em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#wiki_show_mainarea_result_info {
|
#wiki_show_mainarea_result_info {
|
||||||
|
Loading…
Reference in New Issue
Block a user