diff --git a/CHANGELOG b/CHANGELOG index c94ccca6..7a29f434 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Don't break task descriptions on a period that appears in the middle of a sentence [Jamis Buck] + * Added support for :on_error => :continue in task definitions, allowing tasks to effectively ignore connection and execution errors that occur as they run [Rob Holland] * Use correct parameters for Logger constructor in the SCM and Strategy base initializers [Jamis Buck] diff --git a/lib/capistrano/task_definition.rb b/lib/capistrano/task_definition.rb index 0209a3cd..58273f94 100644 --- a/lib/capistrano/task_definition.rb +++ b/lib/capistrano/task_definition.rb @@ -49,7 +49,7 @@ module Capistrano # given, the result will be truncated if it is longer than +max_length+, # and an ellipsis appended. def brief_description(max_length=nil) - brief = description[/^.*?\./] || description + brief = description[/^.*?\.(?=\s|$)/] || description if max_length && brief.length > max_length brief = brief[0,max_length-3] + "..." diff --git a/test/task_definition_test.rb b/test/task_definition_test.rb index 3f3e6eec..3e0a1b1b 100644 --- a/test/task_definition_test.rb +++ b/test/task_definition_test.rb @@ -79,15 +79,23 @@ class TaskDefinitionTest < Test::Unit::TestCase assert_equal "Here is a line wrapped with spacing in it.\n\n foo bar\n baz bang", task.description end - def test_task_brief_description_should_return_first_sentence_in_description + def test_brief_description_should_return_first_sentence_in_description desc = "This is the task. It does all kinds of things." task = new_task(:testing, @namespace, :desc => desc) assert_equal "This is the task.", task.brief_description end - def test_task_brief_description_should_truncate_if_length_given + def test_brief_description_should_truncate_if_length_given desc = "This is the task that does all kinds of things. And then some." task = new_task(:testing, @namespace, :desc => desc) assert_equal "This is the task ...", task.brief_description(20) end + + def test_brief_description_should_not_break_at_period_in_middle_of_sentence + task = new_task(:testing, @namespace, :desc => "Take file.txt and copy it.") + assert_equal "Take file.txt and copy it.", task.brief_description + + task = new_task(:testing, @namespace, :desc => "Take file.txt and copy it. Then do something else.") + assert_equal "Take file.txt and copy it.", task.brief_description + end end \ No newline at end of file