Indefero

Indefero Commit Details


Date:2008-11-25 13:11:09 (16 years 5 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
Commit:4dc074776929fb75a7c2ba2254404654e9aff295
Parents: 6bee793704e44dc8084b863edb54c98d2ab931f9
Message:Added the download of a commit diff.

This fixes issue 50.
Changes:

File differences

src/IDF/Views/Source.php
232232
233233
234234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
235254
236255
237256
                                               $request);
    }
    public $downloadDiff_precond = array('IDF_Precondition::accessSource');
    public function downloadDiff($request, $match)
    {
        $scm = IDF_Scm::get($request);
        $commit = $match[2];
        $branches = $scm->getBranches();
        if ('commit' != $scm->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);
        }
        $cobject = $scm->getCommit($commit);
        $rep = new Pluf_HTTP_Response($cobject->changes, 'text/plain');
        $rep->headers['Content-Disposition'] = 'attachment; filename="'.$commit.'.diff"';
        return $rep;
    }
    /**
     * Should only be called through self::tree
     */
src/IDF/conf/urls.php
171171
172172
173173
174
175
176
177
178
179
174180
175181
176182
               'model' => 'IDF_Views_Source',
               'method' => 'commit');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/source/ddiff/([^/]+)/$#',
               'base' => $base,
               'priority' => 4,
               'model' => 'IDF_Views_Source',
               'method' => 'downloadDiff');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/source/download/([^/]+)/$#',
               'base' => $base,
               'priority' => 4,
src/IDF/templates/idf/source/commit.html
3131
3232
3333
34
35
36
3437
3538
3639
<h2>{trans 'Change Details'}</h2>
{$diff.as_html()}
{aurl 'url', 'IDF_Views_Source::downloadDiff', array($project.shortname, $commit)}
<p class="right soft"><a href="{$url}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/package-grey.png'}" alt="{trans 'Archive'}" align="bottom" /></a> <a href="{$url}">{trans 'Download the diff file'}</a></p>
{/if}
{/block}
{block context}

Archive Download the corresponding diff file

Page rendered in 0.16921s using 14 queries.