Added the display of the repository size in the source subtab of a project.

This commit is contained in:
Loic d'Anterroches
2009-06-19 17:31:45 +02:00
parent e235242ea6
commit 25e296fbb6
7 changed files with 62 additions and 1 deletions

View File

@@ -41,6 +41,14 @@ class IDF_Scm_Git extends IDF_Scm
$this->project = $project;
}
public function getRepositorySize()
{
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs '
.escapeshellarg($this->repo);
$out = split(' ', shell_exec($cmd), 2);
return (int) $out[0];
}
public function isAvailable()
{
try {

View File

@@ -33,6 +33,14 @@ class IDF_Scm_Mercurial extends IDF_Scm
$this->project = $project;
}
public function getRepositorySize()
{
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs '
.escapeshellarg($this->repo);
$out = split(' ', shell_exec($cmd), 2);
return (int) $out[0];
}
public static function factory($project)
{
$rep = sprintf(Pluf::f('mercurial_repositories'), $project->shortname);

View File

@@ -51,6 +51,17 @@ class IDF_Scm_Svn extends IDF_Scm
return true;
}
public function getRepositorySize()
{
if (strpos($this->repo, 'file://') !== 0) {
return -1;
}
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs '
.escapeshellarg(substr($this->repo, 7));
$out = split(' ', shell_exec($cmd), 2);
return (int) $out[0];
}
/**
* Given the string describing the author from the log find the
* author in the database.