Change Details
| src/IDF/Project.php |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | * Get the repository size. |
| 354 | * |
| 355 | * @param bool Force to skip the cache (false) |
| 356 | * @return int Size in byte or -1 if not available |
| 357 | */ |
| 358 | public function getRepositorySize($force=false) |
| 359 | { |
| 360 | $last_eval = $this->getConf()->getVal('repository_size_check_date', 0); |
| 361 | if (!$force and $last_eval > time()-86400) { |
| 362 | return $this->getConf()->getVal('repository_size', -1); |
| 363 | } |
| 364 | $scm = IDF_Scm::get($this); |
| 365 | $this->getConf()->setVal('repository_size', $scm->getRepositorySize()); |
| 366 | $this->getConf()->setVal('repository_size_check_date', time()); |
| 367 | return $this->getConf()->getVal('repository_size', -1); |
| 368 | } |
| 369 | |
| 370 | /** |
| 353 | 371 | * Get the access url to the repository. |
| 354 | 372 | * |
| 355 | 373 | * This will return the right url based on the user. |
| src/IDF/Scm.php |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | * Return the size of the repository in bytes. |
| 92 | * |
| 93 | * @return int Size in byte, -1 if the size cannot be evaluated. |
| 94 | */ |
| 95 | public function getRepositorySize() |
| 96 | { |
| 97 | return -1; |
| 98 | } |
| 99 | |
| 100 | /** |
| 91 | 101 | * Returns the URL of the git daemon. |
| 92 | 102 | * |
| 93 | 103 | * @param IDF_Project |
| src/IDF/Scm/Git.php |
| 41 | 41 | $this->project = $project; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | public function getRepositorySize() |
| 45 | { |
| 46 | $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs ' |
| 47 | .escapeshellarg($this->repo); |
| 48 | $out = split(' ', shell_exec($cmd), 2); |
| 49 | return (int) $out[0]; |
| 50 | } |
| 51 | |
| 44 | 52 | public function isAvailable() |
| 45 | 53 | { |
| 46 | 54 | try { |
| src/IDF/Scm/Mercurial.php |
| 33 | 33 | $this->project = $project; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | public function getRepositorySize() |
| 37 | { |
| 38 | $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs ' |
| 39 | .escapeshellarg($this->repo); |
| 40 | $out = split(' ', shell_exec($cmd), 2); |
| 41 | return (int) $out[0]; |
| 42 | } |
| 43 | |
| 36 | 44 | public static function factory($project) |
| 37 | 45 | { |
| 38 | 46 | $rep = sprintf(Pluf::f('mercurial_repositories'), $project->shortname); |
| src/IDF/Scm/Svn.php |
| 51 | 51 | return true; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | public function getRepositorySize() |
| 55 | { |
| 56 | if (strpos($this->repo, 'file://') !== 0) { |
| 57 | return -1; |
| 58 | } |
| 59 | $cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -bs ' |
| 60 | .escapeshellarg(substr($this->repo, 7)); |
| 61 | $out = split(' ', shell_exec($cmd), 2); |
| 62 | return (int) $out[0]; |
| 63 | } |
| 64 | |
| 54 | 65 | /** |
| 55 | 66 | * Given the string describing the author from the log find the |
| 56 | 67 | * author in the database. |
| src/IDF/Views/Project.php |
| 510 | 510 | 'remote_svn' => $remote_svn, |
| 511 | 511 | 'repository_access' => $prj->getRemoteAccessUrl(), |
| 512 | 512 | 'repository_type' => $repository_type, |
| 513 | 'repository_size' => $prj->getRepositorySize(), |
| 513 | 514 | 'page_title' => $title, |
| 514 | 515 | 'form' => $form, |
| 515 | 516 | ), |
| src/IDF/templates/idf/admin/source.html |
| 20 | 20 | <th>{trans 'Repository access:'}</th> |
| 21 | 21 | <td>{$repository_access} |
| 22 | 22 | </td> |
| 23 | | </tr>{if $remote_svn} |
| 23 | </tr>{if $repository_size != -1} |
| 24 | <tr> |
| 25 | <th>{trans 'Repository size:'}</th> |
| 26 | <td>{$repository_size|size} |
| 27 | </td> |
| 28 | </tr>{/if}{if $remote_svn} |
| 24 | 29 | <tr> |
| 25 | 30 | <th>{$form.f.svn_username.labelTag}:</th> |
| 26 | 31 | <td>{if $form.f.svn_username.errors}{$form.f.svn_username.fieldErrors}{/if} |
Download the corresponding diff file