@@ -55,8 +55,9 class Changeset < ActiveRecord::Base | |||||
55 | ref_keywords = Setting.commit_ref_keywords.downcase.split(",") |
|
55 | ref_keywords = Setting.commit_ref_keywords.downcase.split(",") | |
56 | # keywords used to fix issues |
|
56 | # keywords used to fix issues | |
57 | fix_keywords = Setting.commit_fix_keywords.downcase.split(",") |
|
57 | fix_keywords = Setting.commit_fix_keywords.downcase.split(",") | |
58 | # status applied |
|
58 | # status and optional done ratio applied | |
59 | fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id) |
|
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 | kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw.strip)}.join("|") |
|
62 | kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw.strip)}.join("|") | |
62 | return if kw_regexp.blank? |
|
63 | return if kw_regexp.blank? | |
@@ -75,6 +76,7 class Changeset < ActiveRecord::Base | |||||
75 | # don't change the status is the issue is already closed |
|
76 | # don't change the status is the issue is already closed | |
76 | next if issue.status.is_closed? |
|
77 | next if issue.status.is_closed? | |
77 | issue.status = fix_status |
|
78 | issue.status = fix_status | |
|
79 | issue.done_ratio = done_ratio if done_ratio | |||
78 | issue.save |
|
80 | issue.save | |
79 | end |
|
81 | end | |
80 | end |
|
82 | end |
@@ -85,6 +85,7 | |||||
85 | <p><label><%= l(:setting_commit_fix_keywords) %></label> |
|
85 | <p><label><%= l(:setting_commit_fix_keywords) %></label> | |
86 | <%= text_field_tag 'settings[commit_fix_keywords]', Setting.commit_fix_keywords, :size => 30 %> |
|
86 | <%= text_field_tag 'settings[commit_fix_keywords]', Setting.commit_fix_keywords, :size => 30 %> | |
87 | <%= 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) %> |
|
87 | <%= 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 | <%= 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 | <br /><em><%= l(:text_comma_separated) %></em></p> |
|
89 | <br /><em><%= l(:text_comma_separated) %></em></p> | |
89 | </fieldset> |
|
90 | </fieldset> | |
90 |
|
91 |
@@ -61,6 +61,9 commit_fix_keywords: | |||||
61 | commit_fix_status_id: |
|
61 | commit_fix_status_id: | |
62 | format: int |
|
62 | format: int | |
63 | default: 0 |
|
63 | default: 0 | |
|
64 | commit_fix_done_ratio: | |||
|
65 | format: int | |||
|
66 | default: 100 | |||
64 | # autologin duration in days |
|
67 | # autologin duration in days | |
65 | # 0 means autologin is disabled |
|
68 | # 0 means autologin is disabled | |
66 | autologin: |
|
69 | autologin: |
@@ -39,7 +39,8 class RepositoryTest < Test::Unit::TestCase | |||||
39 | def test_scan_changesets_for_issue_ids |
|
39 | def test_scan_changesets_for_issue_ids | |
40 | # choosing a status to apply to fix issues |
|
40 | # choosing a status to apply to fix issues | |
41 | Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id |
|
41 | Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id | |
42 |
|
42 | Setting.commit_fix_done_ratio = "90" | ||
|
43 | ||||
43 | # make sure issue 1 is not already closed |
|
44 | # make sure issue 1 is not already closed | |
44 | assert !Issue.find(1).status.is_closed? |
|
45 | assert !Issue.find(1).status.is_closed? | |
45 |
|
46 | |||
@@ -47,8 +48,10 class RepositoryTest < Test::Unit::TestCase | |||||
47 | assert_equal [101, 102], Issue.find(3).changeset_ids |
|
48 | assert_equal [101, 102], Issue.find(3).changeset_ids | |
48 |
|
49 | |||
49 | # fixed issues |
|
50 | # fixed issues | |
50 | assert Issue.find(1).status.is_closed? |
|
51 | fixed_issue = Issue.find(1) | |
51 | assert_equal [101], Issue.find(1).changeset_ids |
|
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 | # ignoring commits referencing an issue of another project |
|
56 | # ignoring commits referencing an issue of another project | |
54 | assert_equal [], Issue.find(4).changesets |
|
57 | assert_equal [], Issue.find(4).changesets |
General Comments 0
You need to be logged in to leave comments.
Login now