@@ -1,74 +1,75 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class RepositoriesController < ApplicationController |
|
18 | class RepositoriesController < ApplicationController | |
19 | layout 'base' |
|
19 | layout 'base' | |
20 | before_filter :find_project, :authorize |
|
20 | before_filter :find_project, :authorize | |
21 |
|
21 | |||
22 | def show |
|
22 | def show | |
23 | @entries = @repository.scm.entries('') |
|
23 | @entries = @repository.scm.entries('') | |
24 | show_error and return unless @entries |
|
24 | show_error and return unless @entries | |
25 | @latest_revision = @entries.revisions.latest |
|
25 | @latest_revision = @entries.revisions.latest | |
26 | end |
|
26 | end | |
27 |
|
27 | |||
28 | def browse |
|
28 | def browse | |
29 | @entries = @repository.scm.entries(@path, @rev) |
|
29 | @entries = @repository.scm.entries(@path, @rev) | |
30 | show_error and return unless @entries |
|
30 | show_error and return unless @entries | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def revisions |
|
33 | def revisions | |
34 | @entry = @repository.scm.entry(@path, @rev) |
|
34 | @entry = @repository.scm.entry(@path, @rev) | |
35 | @revisions = @repository.scm.revisions(@path, @rev) |
|
35 | @revisions = @repository.scm.revisions(@path, @rev) | |
36 | show_error and return unless @entry && @revisions |
|
36 | show_error and return unless @entry && @revisions | |
37 | end |
|
37 | end | |
38 |
|
38 | |||
39 | def entry |
|
39 | def entry | |
40 | if 'raw' == params[:format] |
|
40 | if 'raw' == params[:format] | |
41 | content = @repository.scm.cat(@path, @rev) |
|
41 | content = @repository.scm.cat(@path, @rev) | |
42 | show_error and return unless content |
|
42 | show_error and return unless content | |
43 | send_data content, :filename => @path.split('/').last |
|
43 | send_data content, :filename => @path.split('/').last | |
44 | end |
|
44 | end | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | def revision |
|
47 | def revision | |
48 | @revisions = @repository.scm.revisions '', @rev, @rev, :with_paths => true |
|
48 | @revisions = @repository.scm.revisions '', @rev, @rev, :with_paths => true | |
49 | show_error and return unless @revisions |
|
49 | show_error and return unless @revisions | |
50 | @revision = @revisions.first |
|
50 | @revision = @revisions.first | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | def diff |
|
53 | def diff | |
54 | @rev_to = params[:rev_to] || (@rev-1) |
|
54 | @rev_to = params[:rev_to] || (@rev-1) | |
55 | @diff = @repository.scm.diff(params[:path], @rev, @rev_to) |
|
55 | @diff = @repository.scm.diff(params[:path], @rev, @rev_to) | |
56 | show_error and return unless @diff |
|
56 | show_error and return unless @diff | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | private |
|
59 | private | |
60 | def find_project |
|
60 | def find_project | |
61 | @project = Project.find(params[:id]) |
|
61 | @project = Project.find(params[:id]) | |
62 | @repository = @project.repository |
|
62 | @repository = @project.repository | |
|
63 | render_404 and return false unless @repository | |||
63 | @path = params[:path].squeeze('/').gsub(/^\//, '') if params[:path] |
|
64 | @path = params[:path].squeeze('/').gsub(/^\//, '') if params[:path] | |
64 | @path ||= '' |
|
65 | @path ||= '' | |
65 | @rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0 |
|
66 | @rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0 | |
66 | rescue ActiveRecord::RecordNotFound |
|
67 | rescue ActiveRecord::RecordNotFound | |
67 | render_404 |
|
68 | render_404 | |
68 | end |
|
69 | end | |
69 |
|
70 | |||
70 | def show_error |
|
71 | def show_error | |
71 | flash.now[:notice] = l(:notice_scm_error) |
|
72 | flash.now[:notice] = l(:notice_scm_error) | |
72 | render :nothing => true, :layout => true |
|
73 | render :nothing => true, :layout => true | |
73 | end |
|
74 | end | |
74 | end |
|
75 | end |
General Comments 0
You need to be logged in to leave comments.
Login now