Added the display of the repository size in the source subtab of a project.
This commit is contained in:
parent
e235242ea6
commit
25e296fbb6
@ -349,6 +349,24 @@ class IDF_Project extends Pluf_Model
|
|||||||
return new Pluf_Template_ContextVars($tags);
|
return new Pluf_Template_ContextVars($tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the repository size.
|
||||||
|
*
|
||||||
|
* @param bool Force to skip the cache (false)
|
||||||
|
* @return int Size in byte or -1 if not available
|
||||||
|
*/
|
||||||
|
public function getRepositorySize($force=false)
|
||||||
|
{
|
||||||
|
$last_eval = $this->getConf()->getVal('repository_size_check_date', 0);
|
||||||
|
if (!$force and $last_eval > time()-86400) {
|
||||||
|
return $this->getConf()->getVal('repository_size', -1);
|
||||||
|
}
|
||||||
|
$scm = IDF_Scm::get($this);
|
||||||
|
$this->getConf()->setVal('repository_size', $scm->getRepositorySize());
|
||||||
|
$this->getConf()->setVal('repository_size_check_date', time());
|
||||||
|
return $this->getConf()->getVal('repository_size', -1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the access url to the repository.
|
* Get the access url to the repository.
|
||||||
*
|
*
|
||||||
|
@ -87,6 +87,16 @@ class IDF_Scm
|
|||||||
return call_user_func(array($scms[$scm], 'factory'), $project);
|
return call_user_func(array($scms[$scm], 'factory'), $project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the size of the repository in bytes.
|
||||||
|
*
|
||||||
|
* @return int Size in byte, -1 if the size cannot be evaluated.
|
||||||
|
*/
|
||||||
|
public function getRepositorySize()
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the URL of the git daemon.
|
* Returns the URL of the git daemon.
|
||||||
*
|
*
|
||||||
|
@ -41,6 +41,14 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
$this->project = $project;
|
$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()
|
public function isAvailable()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -33,6 +33,14 @@ class IDF_Scm_Mercurial extends IDF_Scm
|
|||||||
$this->project = $project;
|
$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)
|
public static function factory($project)
|
||||||
{
|
{
|
||||||
$rep = sprintf(Pluf::f('mercurial_repositories'), $project->shortname);
|
$rep = sprintf(Pluf::f('mercurial_repositories'), $project->shortname);
|
||||||
|
@ -51,6 +51,17 @@ class IDF_Scm_Svn extends IDF_Scm
|
|||||||
return true;
|
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
|
* Given the string describing the author from the log find the
|
||||||
* author in the database.
|
* author in the database.
|
||||||
|
@ -510,6 +510,7 @@ class IDF_Views_Project
|
|||||||
'remote_svn' => $remote_svn,
|
'remote_svn' => $remote_svn,
|
||||||
'repository_access' => $prj->getRemoteAccessUrl(),
|
'repository_access' => $prj->getRemoteAccessUrl(),
|
||||||
'repository_type' => $repository_type,
|
'repository_type' => $repository_type,
|
||||||
|
'repository_size' => $prj->getRepositorySize(),
|
||||||
'page_title' => $title,
|
'page_title' => $title,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
),
|
),
|
||||||
|
@ -20,7 +20,12 @@
|
|||||||
<th>{trans 'Repository access:'}</th>
|
<th>{trans 'Repository access:'}</th>
|
||||||
<td>{$repository_access}
|
<td>{$repository_access}
|
||||||
</td>
|
</td>
|
||||||
</tr>{if $remote_svn}
|
</tr>{if $repository_size != -1}
|
||||||
|
<tr>
|
||||||
|
<th>{trans 'Repository size:'}</th>
|
||||||
|
<td>{$repository_size|size}
|
||||||
|
</td>
|
||||||
|
</tr>{/if}{if $remote_svn}
|
||||||
<tr>
|
<tr>
|
||||||
<th>{$form.f.svn_username.labelTag}:</th>
|
<th>{$form.f.svn_username.labelTag}:</th>
|
||||||
<td>{if $form.f.svn_username.errors}{$form.f.svn_username.fieldErrors}{/if}
|
<td>{if $form.f.svn_username.errors}{$form.f.svn_username.fieldErrors}{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user