summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-03-24 17:12:44 +0100
committerJohan Sørensen <johan@johansorensen.com>2009-04-22 15:17:25 +0200
commit1bc4cebe1c02ec767506c81c3715386163d7347e (patch)
tree8157eef333285d259c56d7da9d37c532ec92f052
parent49a700e87c454762c46b0647183c8db83c94d439 (diff)
downloadgitorious-mainline-outdated-1bc4cebe1c02ec767506c81c3715386163d7347e.zip
gitorious-mainline-outdated-1bc4cebe1c02ec767506c81c3715386163d7347e.tar.gz
gitorious-mainline-outdated-1bc4cebe1c02ec767506c81c3715386163d7347e.tar.bz2
Make sure the initial commit in a repository is treated specially
Eg we don't try and show a diff, since it can potentially be huge, just link to the tree instead.
-rw-r--r--app/controllers/commits_controller.rb2
-rw-r--r--test/functional/commits_controller_test.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb
index 321d3f8..5ca6c66 100644
--- a/app/controllers/commits_controller.rb
+++ b/app/controllers/commits_controller.rb
@@ -52,7 +52,7 @@ class CommitsController < ApplicationController
end
if stale_conditional?(@commit.id, @commit.committed_date.utc)
@root = Breadcrumb::Commit.new(:repository => @repository, :id => @commit.id_abbrev)
- @diffs = @commit.diffs
+ @diffs = @commit.parents.empty? ? [] : @commit.diffs
@comment_count = @repository.comments.count(:all, :conditions => {:sha1 => @commit.id.to_s})
@committer_user = User.find_by_email_with_aliases(@commit.committer.email)
@author_user = User.find_by_email_with_aliases(@commit.author.email)
diff --git a/test/functional/commits_controller_test.rb b/test/functional/commits_controller_test.rb
index f89698a..885bef6 100644
--- a/test/functional/commits_controller_test.rb
+++ b/test/functional/commits_controller_test.rb
@@ -91,6 +91,16 @@ class CommitsControllerTest < ActionController::TestCase
assert_match(/no such sha/i, flash[:error])
assert_redirected_to project_repository_commits_path(@project, @repository)
end
+
+ should "not show diffs for the initial commit" do
+ commit = @grit.commit(@sha)
+ commit.stubs(:parents).returns([])
+ @grit.expects(:commit).returns(commit)
+ get :show, {:project_id => @project.to_param,
+ :repository_id => @repository.to_param, :id => @sha}
+ assert_equal [], assigns(:diffs)
+ assert_select "#content p", /This is the initial commit in this repository/
+ end
end
context "Routing" do