diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2006-12-24 13:38:45 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2006-12-24 13:38:45 +0000 |
commit | bc4415850105225b101cdea075b04d44b8700108 (patch) | |
tree | ff4711655b34aa5aca5528665d7c18db2583c879 /app/controllers | |
parent | 918123cd0663803a6e392c6c9ce209d10c8e5603 (diff) | |
download | redmine-bc4415850105225b101cdea075b04d44b8700108.tar.gz redmine-bc4415850105225b101cdea075b04d44b8700108.zip |
svn browser merged in trunk
git-svn-id: http://redmine.rubyforge.org/svn/trunk@106 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/repositories_controller.rb | 72 |
2 files changed, 87 insertions, 1 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b0b00bebf..e4a47d3d1 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -62,6 +62,10 @@ class ProjectsController < ApplicationController @project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
@project.custom_values = @custom_values
+ if params[:repository_enabled] && params[:repository_enabled] == "1"
+ @project.repository = Repository.new
+ @project.repository.attributes = params[:repository]
+ end
if @project.save flash[:notice] = l(:notice_successful_create) redirect_to :controller => 'admin', :action => 'projects'
@@ -96,7 +100,17 @@ class ProjectsController < ApplicationController @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
@project.custom_values = @custom_values
end
- if @project.update_attributes(params[:project]) + if params[:repository_enabled]
+ case params[:repository_enabled]
+ when "0"
+ @project.repository = nil
+ when "1"
+ @project.repository ||= Repository.new
+ @project.repository.attributes = params[:repository]
+ end
+ end
+ @project.attributes = params[:project]
+ if @project.save flash[:notice] = l(:notice_successful_update) redirect_to :action => 'settings', :id => @project
else
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb new file mode 100644 index 000000000..9dbbfebd9 --- /dev/null +++ b/app/controllers/repositories_controller.rb @@ -0,0 +1,72 @@ +# redMine - project management software +# Copyright (C) 2006 Jean-Philippe Lang +# +# This program 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. +# +# This program 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class RepositoriesController < ApplicationController + layout 'base' + before_filter :find_project, :authorize + + def show + @entries = @repository.scm.entries('') + show_error and return unless @entries + @latest_revision = @entries.revisions.latest + end + + def browse + @entries = @repository.scm.entries(@path, @rev) + show_error and return unless @entries + end + + def revisions + @entry = @repository.scm.entry(@path, @rev) + @revisions = @repository.scm.revisions(@path, @rev) + show_error and return unless @entry && @revisions + end + + def entry + if 'raw' == params[:format] + content = @repository.scm.cat(@path, @rev) + show_error and return unless content + send_data content, :filename => @path.split('/').last + end + end + + def revision + @revisions = @repository.scm.revisions '', @rev, @rev, :with_paths => true + show_error and return unless @revisions + @revision = @revisions.first + end + + def diff + @rev_to = params[:rev_to] || (@rev-1) + @diff = @repository.scm.diff(params[:path], @rev, @rev_to) + show_error and return unless @diff + end + +private + def find_project + @project = Project.find(params[:id]) + @repository = @project.repository + @path = params[:path].squeeze('/').gsub(/^\//, '') if params[:path] + @path ||= '' + @rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0 + end + + def show_error + flash.now[:notice] = l(:notice_scm_error) + render :nothing => true, :layout => true + end +end |