Indefero

Indefero Commit Details


Date:2008-08-02 06:51:42 (16 years 4 months ago)
Author:Loic d'Anterroches
Branch:dev, develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3, svn
Commit:49f339c7c502a66b562fe49133ead17a0606119c
Parents: d46ddea543c808845538ee1f4830731c100ca55e
Message:Added the ability to download a zip file of the code at a given commit.

Changes:

File differences

src/IDF/Git.php
301301
302302
303303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
304319
return $res;
}
/**
* Generate the command to create a zip archive at a given commit.
*
* @param string Commit
* @param string Prefix ('git-repo-dump')
* @return string Command
*/
public function getArchiveCommand($commit, $prefix='git-repo-dump/')
{
return sprintf('GIT_DIR=%s git archive --format=zip --prefix=%s %s',
escapeshellarg($this->repo),
escapeshellarg($prefix),
escapeshellarg($commit));
}
}
src/IDF/Views/Source.php
148148
149149
150150
151
152151
153152
154153
......
176175
177176
178177
179
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
180201
181202
182203
public function commit($request, $match)
{
$git = new IDF_Git(Pluf::f('git_repository'));
$commit = $match[2];
$branches = $git->getBranches();
$request);
}
/**
* Get a zip archive of the current commit.
*
*/
public function download($request, $match)
{
$commit = trim($match[2]);
$git = new IDF_Git(Pluf::f('git_repository'));
$branches = $git->getBranches();
if ('commit' != $git->testHash($commit)) {
// Redirect to the first branch
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
array($request->project->shortname,
$branches[0]));
return new Pluf_HTTP_Response_Redirect($url);
}
$base = $request->project->shortname.'-'.$commit;
$cmd = $git->getArchiveCommand($commit, $base.'/');
$rep = new Pluf_HTTP_Response_CommandPassThru($cmd, 'application/x-zip');
$rep->headers['Content-Transfer-Encoding'] = 'binary';
$rep->headers['Content-Disposition'] = 'attachment; filename="'.$base.'.zip"';
return $rep;
}
}
function IDF_Views_Source_PrettySize($size)
src/IDF/conf/views.php
141141
142142
143143
144
145
146
147
148
149
144150
145151
146152
'model' => 'IDF_Views_Source',
'method' => 'commit');
$ctl[] = array('regex' => '#^/p/(\w+)/source/download/(\w+)/$#',
'base' => $base,
'priority' => 4,
'model' => 'IDF_Views_Source',
'method' => 'download');
// ---------- ADMIN --------------------------------------
src/IDF/templates/source/tree.html
22
33
44
5
56
67
78
......
4142
4243
4344
45
46
4447
4548
4649
{block docclass}yui-t1{assign $inSourceTree=true}{/block}
{block body}
<h2><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
<table summary="" class="tree-list">
<thead>
<tr>
{/foreach}
</tbody>
</table>
{aurl 'url', 'IDF_Views_Source::download', array($project.shortname, $commit)}
<p class="right"><a href="{$url}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/package.png'}" alt="{trans 'Archive'}" align="bottom" /></a> <a href="{$url}">{trans 'Download this version'}</a></p>
{/block}
{block context}

Archive Download the corresponding diff file

Page rendered in 0.07936s using 13 queries.