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