##// END OF EJS Templates
Added the ability to set the "done ratio" of issues fixed by commit (original path by Nikolay Solakov, slightly edited)....
Jean-Philippe Lang -
r810:5f10cc867327
parent child
Show More
@@ -55,8 +55,9 class Changeset < ActiveRecord::Base
55 55 ref_keywords = Setting.commit_ref_keywords.downcase.split(",")
56 56 # keywords used to fix issues
57 57 fix_keywords = Setting.commit_fix_keywords.downcase.split(",")
58 # status applied
58 # status and optional done ratio applied
59 59 fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id)
60 done_ratio = Setting.commit_fix_done_ratio.blank? ? nil : Setting.commit_fix_done_ratio.to_i
60 61
61 62 kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw.strip)}.join("|")
62 63 return if kw_regexp.blank?
@@ -75,6 +76,7 class Changeset < ActiveRecord::Base
75 76 # don't change the status is the issue is already closed
76 77 next if issue.status.is_closed?
77 78 issue.status = fix_status
79 issue.done_ratio = done_ratio if done_ratio
78 80 issue.save
79 81 end
80 82 end
@@ -85,6 +85,7
85 85 <p><label><%= l(:setting_commit_fix_keywords) %></label>
86 86 <%= text_field_tag 'settings[commit_fix_keywords]', Setting.commit_fix_keywords, :size => 30 %>
87 87 &nbsp;<%= l(:label_applied_status) %>: <%= select_tag 'settings[commit_fix_status_id]', options_for_select( [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, Setting.commit_fix_status_id) %>
88 &nbsp;<%= l(:field_done_ratio) %>: <%= select_tag 'settings[commit_fix_done_ratio]', options_for_select( [[l(:label_no_change_option), '']] + ((0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }), Setting.commit_fix_done_ratio) %>
88 89 <br /><em><%= l(:text_comma_separated) %></em></p>
89 90 </fieldset>
90 91
@@ -61,6 +61,9 commit_fix_keywords:
61 61 commit_fix_status_id:
62 62 format: int
63 63 default: 0
64 commit_fix_done_ratio:
65 format: int
66 default: 100
64 67 # autologin duration in days
65 68 # 0 means autologin is disabled
66 69 autologin:
@@ -39,6 +39,7 class RepositoryTest < Test::Unit::TestCase
39 39 def test_scan_changesets_for_issue_ids
40 40 # choosing a status to apply to fix issues
41 41 Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id
42 Setting.commit_fix_done_ratio = "90"
42 43
43 44 # make sure issue 1 is not already closed
44 45 assert !Issue.find(1).status.is_closed?
@@ -47,8 +48,10 class RepositoryTest < Test::Unit::TestCase
47 48 assert_equal [101, 102], Issue.find(3).changeset_ids
48 49
49 50 # fixed issues
50 assert Issue.find(1).status.is_closed?
51 assert_equal [101], Issue.find(1).changeset_ids
51 fixed_issue = Issue.find(1)
52 assert fixed_issue.status.is_closed?
53 assert_equal 90, fixed_issue.done_ratio
54 assert_equal [101], fixed_issue.changeset_ids
52 55
53 56 # ignoring commits referencing an issue of another project
54 57 assert_equal [], Issue.find(4).changesets
General Comments 0
You need to be logged in to leave comments. Login now