initial commit of scm support:

* svn browsing
* diff viewing

git-svn-id: http://redmine.rubyforge.org/svn/branches/work@102 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2006-12-23 16:13:40 +00:00
parent fa820c0224
commit 9db7b56f4d
24 changed files with 521 additions and 6 deletions
+15 -1
View File
@@ -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
@@ -0,0 +1,44 @@
class RepositoriesController < ApplicationController
layout 'base'
before_filter :find_project
def show
end
def browse
@rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0
@entry = @repository.scm.entry(@path, @rev)
redirect_to :action => 'show', :id => @project and return unless @entry
if @entry.is_dir?
# if entry is a dir, shows directory listing
@entries = @repository.scm.entries(@path, @rev)
redirect_to :action => 'show', :id => @project and return unless @entries
else
# else, shows file's revisions
@revisions = @repository.scm.revisions(@path, @rev)
redirect_to :action => 'show', :id => @project and return unless @revisions
render :action => 'entry_revisions'
end
end
def revision
@rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0
@revisions = @repository.scm.revisions '', @rev, @rev, :with_paths => true
redirect_to :action => 'show', :id => @project and return unless @revisions
@revision = @revisions.first
end
def diff
@rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0
@rev_to = params[:rev_to] || (@rev-1)
@diff = @repository.scm.diff(params[:path], @rev, @rev_to)
redirect_to :action => 'show', :id => @project 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]
end
end