diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-11-20 12:07:28 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-11-20 12:07:28 +0000 |
commit | 99f9aea80a2bc43cdfc2933728f0ab72d7bf99d5 (patch) | |
tree | 840e11fa2d5d72dac774069417e1ad30ce895072 | |
parent | deb182337d14872c5481059382459f5c21502162 (diff) | |
download | redmine-99f9aea80a2bc43cdfc2933728f0ab72d7bf99d5.tar.gz redmine-99f9aea80a2bc43cdfc2933728f0ab72d7bf99d5.zip |
* Referencing issues in commit messages: enter * in 'Referencing keywords' to link any issue id without using keywords.
* Updated Polish translation (Mariusz Olejnik).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@918 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/helpers/application_helper.rb | 2 | ||||
-rw-r--r-- | app/models/changeset.rb | 9 | ||||
-rw-r--r-- | lang/pl.yml | 14 | ||||
-rw-r--r-- | test/unit/changeset_test.rb | 42 | ||||
-rw-r--r-- | test/unit/repository_test.rb | 2 |
5 files changed, 60 insertions, 9 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 80694e744..9c8e9c67d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -231,7 +231,7 @@ module ApplicationHelper # example: # #52 -> <a href="/issues/show/52">#52</a> # r52 -> <a href="/repositories/revision/6?rev=52">r52</a> (project.id is 6) - text = text.gsub(%r{([\s,-^])(#|r)(\d+)(?=[[:punct:]]|\s|<|$)}) do |m| + text = text.gsub(%r{([\s\(,-^])(#|r)(\d+)(?=[[:punct:]]|\s|<|$)}) do |m| leading, otype, oid = $1, $2, $3 link = nil if otype == 'r' diff --git a/app/models/changeset.rb b/app/models/changeset.rb index e4e221732..355a5754c 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -63,6 +63,14 @@ class Changeset < ActiveRecord::Base return if kw_regexp.blank? referenced_issues = [] + + if ref_keywords.delete('*') + # find any issue ID in the comments + target_issue_ids = [] + comments.scan(%r{([\s\(,-^])#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] } + referenced_issues += repository.project.issues.find_all_by_id(target_issue_ids) + end + comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match| action = match[0] target_issue_ids = match[1].scan(/\d+/) @@ -80,6 +88,7 @@ class Changeset < ActiveRecord::Base end referenced_issues += target_issues end + self.issues = referenced_issues.uniq end end diff --git a/lang/pl.yml b/lang/pl.yml index 7796d6d2a..760250e69 100644 --- a/lang/pl.yml +++ b/lang/pl.yml @@ -261,11 +261,11 @@ label_attachment_delete: Skasuj plik label_attachment_plural: Pliki label_report: Raport label_report_plural: Raporty -label_news: Nowość -label_news_new: Dodaj nowość -label_news_plural: Nowości -label_news_latest: Ostatnie nowości -label_news_view_all: Pokaż wszystkie nowości +label_news: Wiadomość +label_news_new: Dodaj wiadomość +label_news_plural: Wiadomości +label_news_latest: Ostatnie wiadomości +label_news_view_all: Pokaż wszystkie wiadomości label_change_log: Lista zmian label_settings: Ustawienia label_overview: Przegląd @@ -334,7 +334,7 @@ label_latest_revision: Ostatnia zmiana label_latest_revision_plural: Ostatnie zmiany label_view_revisions: Pokaż zmiany label_max_size: Maksymalny rozmiar -label_on: 'włączone' +label_on: 'z' label_sort_highest: Przesuń na górę label_sort_higher: Do góry label_sort_lower: Do dołu @@ -544,4 +544,4 @@ mail_body_account_activation_request: 'Zarejestrowano nowego użytkownika: (%s). label_registration_automatic_activation: automatyczna aktywacja kont label_registration_manual_activation: manualna aktywacja kont notice_account_pending: "Twoje konto zostało utworzone i oczekuje na zatwierdzenie administratora." -field_time_zone: Time zone +field_time_zone: Strefa czasowa diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb new file mode 100644 index 000000000..ee53f18ff --- /dev/null +++ b/test/unit/changeset_test.rb @@ -0,0 +1,42 @@ +# redMine - project management software +# Copyright (C) 2006-2007 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. + +require File.dirname(__FILE__) + '/../test_helper' + +class ChangesetTest < Test::Unit::TestCase + fixtures :projects, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :users, :members, :trackers + + def setup + end + + def test_ref_keywords_any + Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id + Setting.commit_fix_done_ratio = '90' + Setting.commit_ref_keywords = '*' + Setting.commit_fix_keywords = 'fixes , closes' + + c = Changeset.new(:repository => Project.find(1).repository, + :committed_on => Time.now, + :comments => 'New commit (#2). Fixes #1') + c.scan_comment_for_issue_ids + + assert_equal [1, 2], c.issue_ids.sort + fixed = Issue.find(1) + assert fixed.closed? + assert_equal 90, fixed.done_ratio + end +end diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb index b802403f5..843b0b42c 100644 --- a/test/unit/repository_test.rb +++ b/test/unit/repository_test.rb @@ -68,7 +68,7 @@ class RepositoryTest < Test::Unit::TestCase COMMENT changeset = Changeset.new( :comments => comment, :commit_date => Time.now, :revision => 0, :scmid => 'f39b7922fb3c', - :committer => 'foo <foo@example.com>', :committed_on => Time.now, :repository_id => repository ) + :committer => 'foo <foo@example.com>', :committed_on => Time.now, :repository => repository ) assert( changeset.save ) assert_not_equal( comment, changeset.comments ) assert_equal( 'This is a loooooooooooooooooooooooooooong comment', changeset.comments ) |