InDefero

Sign in or create your account | Project List | Help

InDefero Commit Details

Date:2009-06-19 17:31:45 (1 year 2 months ago)
Author:Loïc d'Anterroches
Commit:25e296fbb63cb487943d11ad5308b923516f4aaa
Message:Added the display of the repository size in the source subtab of a project.

Files: src/IDF/Project.php (1 diff)
src/IDF/Scm.php (1 diff)
src/IDF/Scm/Git.php (1 diff)
src/IDF/Scm/Mercurial.php (1 diff)
src/IDF/Scm/Svn.php (1 diff)
src/IDF/Views/Project.php (1 diff)
src/IDF/templates/idf/admin/source.html (1 diff)

Change Details

src/IDF/Project.php
350350    }
351351
352352    /**
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    /**
353371     * Get the access url to the repository.
354372     *
355373     * This will return the right url based on the user.
src/IDF/Scm.php
8888    }
8989
9090    /**
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    /**
91101     * Returns the URL of the git daemon.
92102     *
93103     * @param IDF_Project
src/IDF/Scm/Git.php
4141        $this->project = $project;
4242    }
4343
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
4452    public function isAvailable()
4553    {
4654        try {
src/IDF/Scm/Mercurial.php
3333        $this->project = $project;
3434    }
3535
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
3644    public static function factory($project)
3745    {
3846        $rep = sprintf(Pluf::f('mercurial_repositories'), $project->shortname);
src/IDF/Scm/Svn.php
5151        return true;
5252    }
5353
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
5465    /**
5566     * Given the string describing the author from the log find the
5667     * author in the database.
src/IDF/Views/Project.php
510510                                                     'remote_svn' => $remote_svn,
511511                                                     'repository_access' => $prj->getRemoteAccessUrl(),
512512                                                     'repository_type' => $repository_type,
513                                                     'repository_size' => $prj->getRepositorySize(),
513514                                                     'page_title' => $title,
514515                                                     'form' => $form,
515516                                                     ),
src/IDF/templates/idf/admin/source.html
2020<th>{trans 'Repository access:'}</th>
2121<td>{$repository_access}
2222</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}
2429<tr>
2530<th>{$form.f.svn_username.labelTag}:</th>
2631<td>{if $form.f.svn_username.errors}{$form.f.svn_username.fieldErrors}{/if}

Archive Download the corresponding diff file

Branches:
dev
develop
master
newdiff
svn

Tags:
v1.0