Indefero

Indefero Commit Details


Date:2008-08-29 12:50:10 (16 years 3 months ago)
Author:Nicolas LASSALLE
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:ccc41c86b0677ff1d6d79ec1755c34a8ac5e2cab
Parents: 763d7ca7f6cd442e8e7914a69f49edf579ecc6f0
Message:Added support of subversion.

Changes:

File differences

src/IDF/Diff.php
5656
5757
5858
59
60
61
62
63
64
65
66
5967
6068
6169
......
95103
96104
97105
106
107
108
109
110
98111
99112
100113
$current_chunk = 0;
continue;
}
if (0 === strpos($line, 'Index: ')) {
$current_file = self::getSvnFile($line);
$files[$current_file] = array();
$files[$current_file]['chunks'] = array();
$files[$current_file]['chunks_def'] = array();
$current_chunk = 0;
continue;
}
if (0 === strpos($line, '@@ ')) {
$files[$current_file]['chunks_def'][] = self::getChunk($line);
$files[$current_file]['chunks'][] = array();
return trim(substr($line, 3, $n-3));
}
public static function getSvnFile($line)
{
return substr(trim($line), 7);
}
/**
* Return the html version of a parsed diff.
*/
src/IDF/Git.php
4040
4141
4242
43
4344
4445
45
46
4647
4748
4849
......
297298
298299
299300
301
300302
301303
302304
* Test a given object hash.
*
* @param string Object hash.
* @param null to be svn client compatible
* @return mixed false if not valid or 'blob', 'tree', 'commit'
*/
public function testHash($hash)
public function testHash($hash, $dummy=null)
{
$cmd = sprintf('GIT_DIR=%s git cat-file -t %s',
escapeshellarg($this->repo),
}
}
$c['full_message'] = trim($c['full_message']);
$res[] = (object) $c;
return $res;
}
src/IDF/Project.php
336336
337337
338338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
339367
340368
341369
}
/**
* Get the path to the git repository.
*
* @return string Path to the git repository
*/
public function getSvnDaemonUrl()
{
$conf = new IDF_Conf();
$conf->setProject($this);
return $conf->getVal('svn_daemon_url');
}
/**
* Get the root name of the project scm
*
* @return string SCM root
*/
public function getScmRoot()
{
$roots = array('git' => 'master', 'svn' => 'HEAD');
$conf = new IDF_Conf();
$conf->setProject($this);
$scm = $conf->getVal('scm', 'git');
return $roots[$scm];
}
/**
* Check that the object belongs to the project or rise a 404
* error.
*
src/IDF/ScmFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008 CĂ©ondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Manage differents SCM systems
*/
class IDF_ScmFactory
{
/**
* Returns an instance of the correct scm backend object.
*
* @return Object
*/
public static function getScm($request=null)
{
// Get scm type from project conf ; defaults to git
$scm = $request->conf->getVal('scm', 'git');
// CASE: git
if ($scm === 'git') {
return new IDF_Git($request->project->getGitRepository());
}
// CASE: svn
if ($scm === 'svn') {
return new IDF_Svn($request->conf->getVal('svn_repository'),
$request->conf->getVal('svn_username'),
$request->conf->getVal('svn_password'));
}
}
}
src/IDF/Svn.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008 CĂ©ondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* SVN utils.
*
*/
class IDF_Svn
{
public $repo = '';
public $username = '';
public $password = '';
private $assoc = array('dir' => 'tree',
'file' => 'blob');
public function __construct($repo, $username='', $password='')
{
$this->repo = $repo;
$this->username = $username;
$this->password = $password;
}
/**
* Test a given object hash.
*
* @param string Object hash.
* @return mixed false if not valid or 'blob', 'tree', 'commit'
*/
public function testHash($rev, $path='')
{
// OK if HEAD on /
if ($rev === 'HEAD' && $path === '') {
return 'commit';
}
// Else, test the path on revision
$cmd = sprintf('svn info --xml --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$path),
escapeshellarg($rev));
$xmlInfo = shell_exec($cmd);
// If exception is thrown, return false
try {
$xml = simplexml_load_string($xmlInfo);
}
catch (Exception $e) {
return false;
}
// If the entry node does exists, params are wrong
if (!isset($xml->entry)) {
return false;
}
// Else, enjoy it :)
return 'commit';
}
/**
* Given a commit hash returns an array of files in it.
*
* A file is a class with the following properties:
*
* 'perm', 'type', 'size', 'hash', 'file'
*
* @param string Commit ('HEAD')
* @param string Base folder ('')
* @return array
*/
public function filesAtCommit($rev='HEAD', $folder='')
{
$cmd = sprintf('svn ls --xml --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$folder),
escapeshellarg($rev));
$xmlLs = shell_exec($cmd);
$xml = simplexml_load_string($xmlLs);
$res = array();
foreach ($xml->list->entry as $entry) {
$file = array();
$file['type'] = $this->assoc[(String) $entry['kind']];
$file['file'] = (String) $entry->name;
$file['fullpath'] = $folder.'/'.((String) $entry->name);
$file['date'] = gmdate('Y-m-d H:i:s',
strtotime((String) $entry->commit->date));
$file['rev'] = (String) $entry->commit['revision'];
// Get commit message
$currentReposFile = $this->repo.'/'.$folder.'/'.$file['file'];
$file['log'] = $this->getCommitMessage($currentReposFile, $rev);
// Get the size if the type is blob
if ($file['type'] == 'blob') {
$file['size'] = (String) $entry->size;
}
$file['perm'] = '';
$res[] = (Object) $file;
}
return $res;
}
/**
* Get a commit message for given file and revision.
*
* @param string File
* @param string Commit ('HEAD')
*
* @return String commit message
*/
private function getCommitMessage($file, $rev='HEAD')
{
$cmd = sprintf('svn log --xml --limit 1 --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($file),
escapeshellarg($rev));
$xmlLog = shell_exec($cmd);
$xml = simplexml_load_string($xmlLog);
return (String) $xml->logentry->msg;
}
/**
* Get the file info.
*
* @param string File
* @param string Commit ('HEAD')
* @return false Information
*/
public function getFileInfo($totest, $rev='HEAD')
{
$cmd = sprintf('svn info --xml --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$totest),
escapeshellarg($rev));
$xmlInfo = shell_exec($cmd);
$xml = simplexml_load_string($xmlInfo);
$entry = $xml->entry;
$file = array();
$file['fullpath'] = $totest;
$file['hash'] = (String) $entry->repository->uuid;
$file['type'] = $this->assoc[(String) $entry['kind']];
$file['file'] = $totest;
$file['rev'] = (String) $entry->commit['revision'];
$file['author'] = (String) $entry->author;
$file['date'] = gmdate('Y-m-d H:i:s', strtotime((String) $entry->commit->date));
$file['size'] = (String) $entry->size;
$file['log'] = '';
return (Object) $file;
}
/**
* Get a blob.
*
* @param string Blob hash
* @return string Raw blob
*/
public function getBlob($path, $rev)
{
$cmd = sprintf('svn cat --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$path),
escapeshellarg($rev));
return shell_exec($cmd);
}
/**
* Get the branches.
*
* @return array Branches.
*/
public function getBranches()
{
$res = array('HEAD');
return $res;
}
/**
* Get commit details.
*
* @param string Commit ('HEAD').
* @return array Changes.
*/
public function getCommit($rev='HEAD')
{
$res = array();
$cmd = sprintf('svn log --xml -v --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo),
escapeshellarg($rev));
$xmlRes = shell_exec($cmd);
$xml = simplexml_load_string($xmlRes);
$res['author'] = (String) $xml->logentry->author;
$res['date'] = gmdate('Y-m-d H:i:s', strtotime((String) $xml->logentry->date));
$res['title'] = (String) $xml->logentry->msg;
$res['commit'] = (String) $xml->logentry['revision'];
$res['changes'] = $this->getDiff($rev);
$res['tree'] = '';
return (Object) $res;
}
private function getDiff($rev='HEAD')
{
$res = array();
$cmd = sprintf('svn diff -c %s --username=%s --password=%s %s',
escapeshellarg($rev),
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo));
return shell_exec($cmd);
}
/**
* Get latest changes.
*
* @param string Commit ('HEAD').
* @param int Number of changes (10).
*
* @return array Changes.
*/
public function getChangeLog($rev='HEAD', $n=10)
{
$res = array();
$cmd = sprintf('svn log --xml -v --limit %s --username=%s --password=%s %s@%s',
escapeshellarg($n),
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo),
escapeshellarg($rev));
$xmlRes = shell_exec($cmd);
$xml = simplexml_load_string($xmlRes);
$res = array();
foreach ($xml->logentry as $entry) {
$log = array();
$log['author'] = (String) $entry->author;
$log['date'] = gmdate('Y-m-d H:i:s', strtotime((String) $entry->date));
$log['title'] = (String) $entry->msg;
$log['commit'] = (String) $entry['revision'];
$log['full_message'] = '';
$res[] = (Object) $log;
}
return $res;
}
/**
* Generate the command to create a zip archive at a given commit.
* Unsupported feature in subversion
*
* @param string dummy
* @param string dummy
* @return Exception
*/
public function getArchiveCommand($commit, $prefix='git-repo-dump/')
{
throw new Exception(('Unsupported feature.'));
}
/**
* Get additionnals properties on path and revision
*
* @param string File
* @param string Commit ('HEAD')
* @return array
*/
public function getProperties($rev, $path='')
{
$res = array();
$cmd = sprintf('svn proplist --xml --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$path),
escapeshellarg($rev));
$xmlProps = shell_exec($cmd);
$props = simplexml_load_string($xmlProps);
// No properties, returns an empty array
if (!isset($props->target)) {
return $res;
}
// Get the value of each property
foreach ($props->target->property as $prop) {
$key = (String) $prop['name'];
$res[$key] = $this->getProperty($key, $rev, $path);
}
return $res;
}
/**
* Get a specific additionnal property on path and revision
*
* @param string Property
* @param string File
* @param string Commit ('HEAD')
* @return string the property value
*/
private function getProperty($property, $rev, $path='')
{
$res = array();
$cmd = sprintf('svn propget --xml %s --username=%s --password=%s %s@%s',
escapeshellarg($property),
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$path),
escapeshellarg($rev));
$xmlProp = shell_exec($cmd);
$prop = simplexml_load_string($xmlProp);
return (String) $prop->target->property;
}
/**
* Get the number of the last commit in the repository.
*
* @param string Commit ('HEAD').
*
* @return String last number commit
*/
public function getLastCommit($rev='HEAD')
{
$xmlInfo = '';
$cmd = sprintf('svn info --xml --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo),
escapeshellarg($rev));
$xmlInfo = shell_exec($cmd);
$xml = simplexml_load_string($xmlInfo);
return (String) $xml->entry->commit['revision'];
}
}
src/IDF/Views/Source.php
3434
3535
3636
37
38
39
37
38
39
40
4041
41
42
43
4244
4345
4446
......
4648
4749
4850
51
4952
5053
5154
......
5356
5457
5558
56
57
59
60
61
5862
59
60
63
64
6165
6266
6367
6468
6569
6670
67
68
71
72
6973
70
74
75
76
77
78
79
7180
7281
7382
......
7685
7786
7887
88
7989
8090
8191
......
8393
8494
8595
86
87
88
96
97
98
99
89100
90
101
102
91103
92104
93105
94106
95107
96108
97
98
109
99110
100111
101112
......
105116
106117
107118
108
109
119
120
121
122
123
124
125
126
110127
111128
112129
113130
114131
115
132
116133
117
134
118135
119136
120137
121138
122
139
140
141
142
143
144
123145
124146
125147
......
131153
132154
133155
156
134157
135158
136159
......
155178
156179
157180
158
181
159182
160
161
183
184
162185
163186
164187
......
167190
168191
169192
170
193
171194
172195
196
173197
174198
175199
......
178202
179203
180204
205
181206
182207
183208
......
190215
191216
192217
193
194
195
218
219
220
196221
197222
198223
......
200225
201226
202227
203
228
204229
205230
206231
......
208233
209234
210235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
211299
212300
213301
......
238326
239327
240328
329
330
331
332
333
334
335
336
337
338
241339
242340
243341
public $changeLog_precond = array('IDF_Precondition::accessSource');
public function changeLog($request, $match)
{
$title = sprintf(__('%s Git Change Log'), (string) $request->project);
$git = new IDF_Git($request->project->getGitRepository());
$branches = $git->getBranches();
$title = sprintf(__('%s %s Change Log'), (string) $request->project,
$this->getScmType($request));
$scm = IDF_ScmFactory::getScm($request);
$branches = $scm->getBranches();
$commit = $match[2];
$res = $git->getChangeLog($commit, 25);
$res = $scm->getChangeLog($commit, 25);
$scmConf = $request->conf->getVal('scm', 'git');
return Pluf_Shortcuts_RenderToResponse('source/changelog.html',
array(
'page_title' => $title,
'changes' => $res,
'commit' => $commit,
'branches' => $branches,
'scm' => $scmConf,
),
$request);
}
public $treeBase_precond = array('IDF_Precondition::accessSource');
public function treeBase($request, $match)
{
$title = sprintf(__('%s Git Source Tree'), (string) $request->project);
$git = new IDF_Git($request->project->getGitRepository());
$title = sprintf(__('%s %s Source Tree'), (string) $request->project,
$this->getScmType($request));
$scm = IDF_ScmFactory::getScm($request);
$commit = $match[2];
$branches = $git->getBranches();
if ('commit' != $git->testHash($commit)) {
$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);
}
$res = $git->filesAtCommit($commit);
$cobject = $git->getCommit($commit);
$res = $scm->filesAtCommit($commit);
$cobject = $scm->getCommit($commit);
$tree_in = in_array($commit, $branches);
return Pluf_Shortcuts_RenderToResponse('source/tree.html',
$scmConf = $request->conf->getVal('scm', 'git');
$props = null;
if ($scmConf === 'svn') {
$props = $scm->getProperties($commit);
}
return Pluf_Shortcuts_RenderToResponse('source/'.$scmConf.'/tree.html',
array(
'page_title' => $title,
'title' => $title,
'commit' => $commit,
'tree_in' => $tree_in,
'branches' => $branches,
'props' => $props,
),
$request);
}
public $tree_precond = array('IDF_Precondition::accessSource');
public function tree($request, $match)
{
$title = sprintf(__('%s Git Source Tree'), (string) $request->project);
$git = new IDF_Git($request->project->getGitRepository());
$branches = $git->getBranches();
$title = sprintf(__('%s %s Source Tree'), (string) $request->project,
$this->getScmType($request));
$scm = IDF_ScmFactory::getScm($request);
$branches = $scm->getBranches();
$commit = $match[2];
if ('commit' != $git->testHash($commit)) {
$request_file = $match[3];
if ('commit' != $scm->testHash($commit, $request_file)) {
// 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);
}
$request_file = $match[3];
$request_file_info = $git->getFileInfo($request_file, $commit);
$request_file_info = $scm->getFileInfo($request_file, $commit);
if (!$request_file_info) {
// Redirect to the first branch
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
}
if ($request_file_info->type != 'tree') {
$info = self::getMimeType($request_file_info->file);
$rep = new Pluf_HTTP_Response($git->getBlob($request_file_info->hash),
$info[0]);
if (Pluf::f('src') == 'git') {
$rep = new Pluf_HTTP_Response($scm->getBlob($request_file_info->hash),
$info[0]);
}
else {
$rep = new Pluf_HTTP_Response($scm->getBlob($request_file_info->fullpath, $commit),
$info[0]);
}
$rep->headers['Content-Disposition'] = 'attachment; filename="'.$info[1].'"';
return $rep;
}
$bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->file);
$page_title = $bc.' - '.$title;
$cobject = $git->getCommit($commit);
$cobject = $scm->getCommit($commit);
$tree_in = in_array($commit, $branches);
$res = $git->filesAtCommit($commit, $request_file);
$res = $scm->filesAtCommit($commit, $request_file);
// try to find the previous level if it exists.
$prev = split('/', $request_file);
$l = array_pop($prev);
$previous = substr($request_file, 0, -strlen($l.' '));
return Pluf_Shortcuts_RenderToResponse('source/tree.html',
$scmConf = $request->conf->getVal('scm', 'git');
$props = null;
if ($scmConf === 'svn') {
$props = $scm->getProperties($commit, $request_file);
}
return Pluf_Shortcuts_RenderToResponse('source/'.$scmConf.'/tree.html',
array(
'page_title' => $page_title,
'title' => $title,
'prev' => $previous,
'tree_in' => $tree_in,
'branches' => $branches,
'props' => $props,
),
$request);
}
public $commit_precond = array('IDF_Precondition::accessSource');
public function commit($request, $match)
{
$git = new IDF_Git($request->project->getGitRepository());
$scm = IDF_ScmFactory::getScm($request);
$commit = $match[2];
$branches = $git->getBranches();
if ('commit' != $git->testHash($commit)) {
$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,
}
$title = sprintf(__('%s Commit Details'), (string) $request->project);
$page_title = sprintf(__('%s Commit Details - %s'), (string) $request->project, $commit);
$cobject = $git->getCommit($commit);
$cobject = $scm->getCommit($commit);
$diff = new IDF_Diff($cobject->changes);
$diff->parse();
$scmConf = $request->conf->getVal('scm', 'git');
return Pluf_Shortcuts_RenderToResponse('source/commit.html',
array(
'page_title' => $page_title,
'cobject' => $cobject,
'commit' => $commit,
'branches' => $branches,
'scm' => $scmConf,
),
$request);
}
public function download($request, $match)
{
$commit = trim($match[2]);
$git = new IDF_Git($request->project->getGitRepository());
$branches = $git->getBranches();
if ('commit' != $git->testHash($commit)) {
$scm = IDF_ScmFactory::getScm($request);
$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,
return new Pluf_HTTP_Response_Redirect($url);
}
$base = $request->project->shortname.'-'.$commit;
$cmd = $git->getArchiveCommand($commit, $base.'/');
$cmd = $scm->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"';
}
/**
* Display tree of a specific SVN revision
*
*/
public function treeRev($request, $match)
{
$prj = $request->project;
// Redirect to tree base if not svn
if ($request->conf->getVal('scm', 'git') != 'svn') {
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
array($prj->shortname, $prj->getScmRoot()));
return new Pluf_HTTP_Response_Redirect($url);
}
// Get revision value
if (!isset($request->REQUEST['rev']) or trim($request->REQUEST['rev']) == '') {
$scmRoot = $prj->getScmRoot();
}
else {
$scmRoot = $request->REQUEST['rev'];
}
// Get source if not /
if (isset($request->REQUEST['sourcefile']) and trim($request->REQUEST['sourcefile']) != '') {
$scmRoot .= '/'.$request->REQUEST['sourcefile'];
}
// Redirect
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
array($prj->shortname, $scmRoot));
return new Pluf_HTTP_Response_Redirect($url);
}
/**
* Display SVN changelog from specific revision
*
*/
public function changelogRev($request, $match)
{
$prj = $request->project;
// Redirect to tree base if not svn
if ($request->conf->getVal('scm', 'git') != 'svn') {
$scmRoot = $prj->getScmRoot();
}
// Get revision value if svn
else {
if (!isset($request->REQUEST['rev']) or trim($request->REQUEST['rev']) == '') {
$scmRoot = $prj->getScmRoot();
}
else {
$scmRoot = $request->REQUEST['rev'];
}
}
// Redirect
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::changeLog',
array($prj->shortname, $scmRoot));
return new Pluf_HTTP_Response_Redirect($url);
}
/**
* Find the mime type of a file.
*
* Use /etc/mime.types to find the type.
}
return array('application/octet-stream', $info['basename']);
}
/**
* Get the scm type for page title
*
* @return String
*/
private function getScmType($request)
{
return ucfirst($scm = $request->conf->getVal('scm', 'git'));
}
}
function IDF_Views_Source_PrettySize($size)
src/IDF/conf/views.php
133133
134134
135135
136
136
137137
138138
139139
......
171171
172172
173173
174
175
176
177
178
179
180
181
182
183
184
185
174186
175187
176188
'model' => 'IDF_Views_Issue',
'method' => 'myIssues');
// ---------- GIT ----------------------------------------
// ---------- SCM ----------------------------------------
$ctl[] = array('regex' => '#^/p/(\w+)/source/$#',
'base' => $base,
'model' => 'IDF_Views_Source',
'method' => 'download');
$ctl[] = array('regex' => '#^/p/(\w+)/source/treerev/$#',
'base' => $base,
'priority' => 4,
'model' => 'IDF_Views_Source',
'method' => 'treeRev');
$ctl[] = array('regex' => '#^/p/(\w+)/source/changesrev/$#',
'base' => $base,
'priority' => 4,
'model' => 'IDF_Views_Source',
'method' => 'changelogRev');
// ---------- Downloads ------------------------------------
$ctl[] = array('regex' => '#^/p/(\w+)/downloads/$#',
src/IDF/templates/base.html
4444
4545
4646
47
47
4848
4949
5050
<a accesskey="1" href="{url 'IDF_Views_Project::home', array($project.shortname)}"{block tabhome}{/block}>{trans 'Project Home'}</a>
{if $hasIssuesAccess} <a href="{url 'IDF_Views_Issue::index', array($project.shortname)}"{block tabissues}{/block}>{trans 'Issues'}</a>{/if}
{if $hasDownloadsAccess} <a href="{url 'IDF_Views_Download::index', array($project.shortname)}"{block tabdownloads}{/block}>{trans 'Downloads'}</a>{/if}
{if $hasSourceAccess} <a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, 'master')}"{block tabsource}{/block}>{trans 'Source'}</a>{/if}
{if $hasSourceAccess} <a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $project.getScmRoot())}"{block tabsource}{/block}>{trans 'Source'}</a>{/if}
{if $isOwner}
<a href="{url 'IDF_Views_Project::admin', array($project.shortname)}"{block tabadmin}{/block}>{trans 'Administer'}</a>{/if}{/if}
</div>
src/IDF/templates/source/base.html
22
33
44
5
6
5
6
77
88
99
{block tabsource} class="active"{/block}
{block subtabs}
<div id="sub-tabs">
<a {if $inSourceTree}class="active" {/if}href="{url 'IDF_Views_Source::treeBase', array($project.shortname, 'master')}">{trans 'Source Tree'}</a> |
<a {if $inChangeLog}class="active" {/if}href="{url 'IDF_Views_Source::changeLog', array($project.shortname, 'master')}">{trans 'Change Log'}</a>
<a {if $inSourceTree}class="active" {/if}href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $project.getScmRoot())}">{trans 'Source Tree'}</a> |
<a {if $inChangeLog}class="active" {/if}href="{url 'IDF_Views_Source::changeLog', array($project.shortname, $project.getScmRoot())}">{trans 'Change Log'}</a>
{if $inCommit}| {trans 'Commit'}{/if}
</div>
{/block}
src/IDF/templates/source/changelog.html
2929
3030
3131
32
3233
3334
3435
3536
3637
3738
39
40
41
42
43
44
45
46
47
3848
3949
</table>
{/block}
{block context}
{if $scm == 'git'}
<p><strong>{trans 'Branches:'}</strong><br />
{foreach $branches as $branch}
{aurl 'url', 'IDF_Views_Source::changeLog', array($project.shortname, $branch)}
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
{/foreach}
</p>
{/if}
{if $scm == 'svn'}
<p><strong>{trans 'Revison:'} {$commit}</strong><br />
<form class="star" action="{url 'IDF_Views_Source::changelogRev', array($project.shortname)}" method="get">
<input accesskey="4" type="text" value="{$commit}" name="rev" size="20" />
<input type="submit" name="s" value="{trans 'Go to revision'}" />
</form>
</p>
{/if}
{/block}
src/IDF/templates/source/commit.html
3636
3737
3838
39
3940
4041
4142
4243
4344
4445
46
4547
4648
{/if}
{/block}
{block context}
{if $scm == 'git'}
<p><strong>{trans 'Branches:'}</strong><br />
{foreach $branches as $branch}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $branch)}
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
{/foreach}
</p>
{/if}
{/block}
src/IDF/templates/source/git/tree.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{extends "source/base.html"}
{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>
<th colspan="2">{trans 'File'}</th>
<th>{trans 'Age'}</th>
<th>{trans 'Message'}</th>
<th>{trans 'Size'}</th>
</tr>
</thead>{if !$tree_in}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
<tfoot>
<tr><th colspan="5">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br />
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
</th></tr>
</tfoot>
{/if}<tbody>
{if $base}
<tr>
<td>&nbsp;</td>
<td>
<a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $prev)}">..</a></td>
<td colspan="3"></td>
</tr>
{/if}
{foreach $files as $file}
{aurl 'url', 'IDF_Views_Source::tree', array($project.shortname, $commit, $file.fullpath)}
<tr>
<td class="fileicon"><img src="{media '/idf/img/'~$file.type~'.png'}" alt="{$file.type}" /></td>
<td{if $file.type != 'blob'} colspan="4"{/if}><a href="{$url}">{$file.file}</a></td>
{if $file.type == 'blob'}
{if isset($file.date)}
<td><span class="smaller">{$file.date|dateago:"wihtout"}</span></td>
<td><span class="smaller">{$file.log}</span></td>
{else}<td colspan="2"></td>{/if}
<td>{$file.size|size}</td>{/if}
</tr>
{/foreach}
</tbody>
</table>
{aurl 'url', 'IDF_Views_Source::download', 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 this version'}</a> {trans 'or'} <kbd>git clone {$project.getGitDaemonUrl()}</kbd></p>
{/block}
{block context}
<p><strong>{trans 'Branches:'}</strong><br />
{foreach $branches as $branch}
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
{/foreach}
</p>
{/block}
src/IDF/templates/source/svn/tree.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{extends "source/base.html"}
{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>
<th colspan="2">{trans 'File'}</th>
<th>{trans 'Age'}</th>
<th>{trans 'Rev'}</th>
<th>{trans 'Message'}</th>
<th>{trans 'Size'}</th>
</tr>
</thead>{if !$tree_in || $props}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
<tfoot>
{if $props}
<tr><th colspan="6">
<ul>
{foreach $props as $prop => $val}
<li>{trans 'Property'} <strong>{$prop}</strong> {trans 'set to:'} <em>{$val}</em></li>
{/foreach}
</ul>
</th></tr>
{/if}
{if !$tree_in}
<tr><th colspan="6">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br />
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
</th></tr>
{/if}
</tfoot>
{/if}<tbody>
{if $base}
<tr>
<td>&nbsp;</td>
<td>
<a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $prev)}">..</a></td>
<td colspan="3"></td>
</tr>
{/if}
{foreach $files as $file}
{aurl 'url', 'IDF_Views_Source::tree', array($project.shortname, $commit, $file.fullpath)}
<tr>
<td class="fileicon"><img src="{media '/idf/img/'~$file.type~'.png'}" alt="{$file.type}" /></td>
<td><a href="{$url}">{$file.file}</a></td>
<td><span class="smaller">{$file.date|dateago:"wihtout"}</span></td>
<td>{$file.rev}</td>
<td{if $file.type != 'blob'} colspan="2"{/if}><span class="smaller">{$file.log|nl2br}</span></td>
{if $file.type == 'blob'}
<td>{$file.size|size}</td>
{/if}
</tr>
{/foreach}
</tbody>
</table>
<p class="right soft"><img style="vertical-align: text-bottom;" src="{media '/idf/img/package-grey.png'}" alt="{trans 'Archive'}" align="bottom" /></a> <kbd>svn checkout {$project.getSvnDaemonUrl()}@{$commit}</kbd></p>
{/block}
{block context}
<p><strong>{trans 'Revison:'} {$commit}</strong><br />
<form class="star" action="{url 'IDF_Views_Source::treeRev', array($project.shortname)}" method="get">
<input accesskey="4" type="text" value="{$commit}" name="rev" size="20" />
<input type="hidden" name="sourcefile" value="{$base}"/>
<input type="submit" name="s" value="{trans 'Go to revision'}" />
</form>
</p>
{/block}
src/IDF/templates/source/tree.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{extends "source/base.html"}
{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>
<th colspan="2">{trans 'File'}</th>
<th>{trans 'Age'}</th>
<th>{trans 'Message'}</th>
<th>{trans 'Size'}</th>
</tr>
</thead>{if !$tree_in}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
<tfoot>
<tr><th colspan="5">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br />
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
</th></tr>
</tfoot>
{/if}<tbody>
{if $base}
<tr>
<td>&nbsp;</td>
<td>
<a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $prev)}">..</a></td>
<td colspan="3"></td>
</tr>
{/if}
{foreach $files as $file}
{aurl 'url', 'IDF_Views_Source::tree', array($project.shortname, $commit, $file.fullpath)}
<tr>
<td class="fileicon"><img src="{media '/idf/img/'~$file.type~'.png'}" alt="{$file.type}" /></td>
<td{if $file.type != 'blob'} colspan="4"{/if}><a href="{$url}">{$file.file}</a></td>
{if $file.type == 'blob'}
{if isset($file.date)}
<td><span class="smaller">{$file.date|dateago:"wihtout"}</span></td>
<td><span class="smaller">{$file.log}</span></td>
{else}<td colspan="2"></td>{/if}
<td>{$file.size|size}</td>{/if}
</tr>
{/foreach}
</tbody>
</table>
{aurl 'url', 'IDF_Views_Source::download', 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 this version'}</a> {trans 'or'} <kbd>git clone {$project.getGitDaemonUrl()}</kbd></p>
{/block}
{block context}
<p><strong>{trans 'Branches:'}</strong><br />
{foreach $branches as $branch}
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
{/foreach}
</p>
{/block}
www/media/idf/css/style.css
330330
331331
332332
333
334
335
336
337
333338
334339
335340
font-weight: normal;
}
table.tree-list tfoot th ul {
text-align: left;
font-size: 85%;
}
table.tree-list tr.log {
border-bottom: 1px solid #e7ebe3;
/* background-color: #eef2ea !important; */

Archive Download the corresponding diff file

Page rendered in 0.14994s using 13 queries.