summaryrefslogtreecommitdiffstats
path: root/app/controllers/comments_controller.rb
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-10-29 14:54:56 +0100
committerJohan Sørensen <johan@johansorensen.com>2009-11-04 15:23:44 +0100
commit1a7b3a0ba79414fc91a3ca117f1c0e1ebbe80a6d (patch)
treeb76d7cbdd744ea2d6bf4e8fa2b5c77a4365c6dbd /app/controllers/comments_controller.rb
parentddd8531a039db5d1b8efd9078ada80d93ce7d4ba (diff)
downloadgitorious-mainline-outdated-1a7b3a0ba79414fc91a3ca117f1c0e1ebbe80a6d.zip
gitorious-mainline-outdated-1a7b3a0ba79414fc91a3ca117f1c0e1ebbe80a6d.tar.gz
gitorious-mainline-outdated-1a7b3a0ba79414fc91a3ca117f1c0e1ebbe80a6d.tar.bz2
Make sure we re-render the diff correctly when commenting on single commit
Diffstat (limited to 'app/controllers/comments_controller.rb')
-rw-r--r--app/controllers/comments_controller.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 63c37ef..a980856 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -76,17 +76,19 @@ class CommentsController < ApplicationController
if @comment.sha1.blank?
redirect_to_repository_or_target
else
- redirect_to repo_owner_path(@repository, :project_repository_commit_path, @project, @repository, @comment.sha1)
+ redirect_to repo_owner_path(@repository,
+ :project_repository_commit_path, @project, @repository, @comment.sha1)
end
end
format.js do
- @diffs = @target.diffs(@comment.sha_range).
- select{|d|d.a_path == @comment.path}
+ @diffs = @target.diffs(range_or_string(@comment.sha1)).select{|d|
+ d.a_path == @comment.path
+ }
render :partial => "merge_request_versions/comments", :status => :created
end
else
format.html { render :action => "new" }
- format.js {render :nothing => true, :status => :not_acceptable}
+ format.js { render :nothing => true, :status => :not_acceptable }
end
end
end
@@ -96,8 +98,17 @@ class CommentsController < ApplicationController
end
protected
+ def range_or_string(str)
+ if match = /^([a-z0-9]*)-([a-z0-9]*)$/.match(str)
+ @sha_range = Range.new(match[1],match[2])
+ else
+ @sha_range = str
+ end
+ end
+
def find_repository
- @repository = @owner.repositories.find_by_name_in_project!(params[:repository_id], @containing_project)
+ @repository = @owner.repositories.find_by_name_in_project!(params[:repository_id],
+ @containing_project)
end
def find_polymorphic_parent