Patch #7445 » commit-update-1.2.1.patch
app/models/changeset.rb | ||
---|---|---|
108 | 108 |
ref_keywords = Setting.commit_ref_keywords.downcase.split(",").collect(&:strip) |
109 | 109 |
ref_keywords_any = ref_keywords.delete('*') |
110 | 110 |
# keywords used to fix issues |
111 |
fix_keywords = Setting.commit_fix_keywords.downcase.split(",").collect(&:strip) |
|
112 | 111 | |
113 |
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") |
|
112 |
ref_updates = |
|
113 |
[ { :keywords => Setting.commit_update1_keywords.downcase.split(",").collect(&:strip), |
|
114 |
:status_id => Setting.commit_update1_status_id, |
|
115 |
:done_ratio => Setting.commit_update1_done_ratio }, |
|
116 |
{ :keywords => Setting.commit_update2_keywords.downcase.split(",").collect(&:strip), |
|
117 |
:status_id => Setting.commit_update2_status_id, |
|
118 |
:done_ratio => Setting.commit_update2_done_ratio }, |
|
119 |
{ :keywords => Setting.commit_update3_keywords.downcase.split(",").collect(&:strip), |
|
120 |
:status_id => Setting.commit_update3_status_id, |
|
121 |
:done_ratio => Setting.commit_update3_done_ratio }, |
|
122 |
{ :keywords => Setting.commit_update4_keywords.downcase.split(",").collect(&:strip), |
|
123 |
:status_id => Setting.commit_update4_status_id, |
|
124 |
:done_ratio => Setting.commit_update4_done_ratio }, |
|
125 |
{ :keywords => Setting.commit_update5_keywords.downcase.split(",").collect(&:strip), |
|
126 |
:status_id => Setting.commit_update5_status_id, |
|
127 |
:done_ratio => Setting.commit_update5_done_ratio } ] |
|
128 | ||
129 |
kw_regexp = (ref_keywords + ref_updates.collect{|u| u[:keywords]}.flatten).collect{|kw| Regexp.escape(kw)}.join("|") |
|
114 | 130 | |
115 | 131 |
referenced_issues = [] |
116 | 132 | |
... | ... | |
121 | 137 |
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m| |
122 | 138 |
issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2] |
123 | 139 |
if issue |
124 |
referenced_issues << issue |
|
125 |
fix_issue(issue) if fix_keywords.include?(action.to_s.downcase) |
|
140 |
# referenced_issues << issue |
|
141 |
# fix_issue(issue) if fix_keywords.include?(action.to_s.downcase) |
|
142 | ||
143 |
referenced_issues << issue |
|
144 |
ref_updates.each do |u| |
|
145 |
update_issue(issue, u[:status_id], u[:done_ratio]) if u[:keywords].include?(action.to_s.downcase) |
|
146 |
end |
|
147 | ||
126 | 148 |
log_time(issue, hours) if hours && Setting.commit_logtime_enabled? |
127 | 149 |
end |
128 | 150 |
end |
... | ... | |
190 | 212 |
issue |
191 | 213 |
end |
192 | 214 | |
193 |
def fix_issue(issue) |
|
194 |
status = IssueStatus.find_by_id(Setting.commit_fix_status_id.to_i) |
|
215 |
# def fix_issue(issue) |
|
216 |
# status = IssueStatus.find_by_id(Setting.commit_fix_status_id.to_i) |
|
217 |
def update_issue(issue, status_id, done_ratio) |
|
218 |
status = IssueStatus.find_by_id(status_id.to_i) |
|
195 | 219 |
if status.nil? |
196 |
logger.warn("No status matches commit_fix_status_id setting (#{Setting.commit_fix_status_id})") if logger |
|
220 |
# logger.warn("No status matches commit_fix_status_id setting (#{Setting.commit_fix_status_id})") if logger |
|
221 |
logger.warn("No status macthes commit_update_status_id setting (#{status_id})") if logger |
|
197 | 222 |
return issue |
198 | 223 |
end |
199 | 224 | |
... | ... | |
204 | 229 | |
205 | 230 |
journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, text_tag)) |
206 | 231 |
issue.status = status |
207 |
unless Setting.commit_fix_done_ratio.blank? |
|
208 |
issue.done_ratio = Setting.commit_fix_done_ratio.to_i |
|
232 |
# unless Setting.commit_fix_done_ratio.blank? |
|
233 |
# issue.done_ratio = Setting.commit_fix_done_ratio.to_i |
|
234 |
unless done_ratio.blank? |
|
235 |
issue.done_ratio = done_ratio.to_i |
|
209 | 236 |
end |
210 | 237 |
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update, |
211 | 238 |
{ :changeset => self, :issue => issue }) |
app/views/settings/_repositories.rhtml | ||
---|---|---|
69 | 69 |
<p><%= setting_text_field :commit_ref_keywords, :size => 30 %><br /> |
70 | 70 |
<em><%= l(:text_comma_separated) %></em></p> |
71 | 71 | |
72 |
<p><%= setting_text_field :commit_fix_keywords, :size => 30 %> |
|
73 |
<%= l(:label_applied_status) %>: <%= setting_select :commit_fix_status_id, |
|
74 |
[["", 0]] + |
|
75 |
IssueStatus.find(:all).collect{ |
|
76 |
|status| [status.name, status.id.to_s] |
|
77 |
}, |
|
78 |
:label => false %> |
|
79 |
<%= l(:field_done_ratio) %>: <%= setting_select :commit_fix_done_ratio, |
|
80 |
(0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }, |
|
81 |
:blank => :label_no_change_option, |
|
82 |
:label => false %> |
|
72 | ||
73 | ||
74 |
<p><%= setting_text_field :commit_update1_keywords, :size => 30 %> |
|
75 |
<%= l(:label_applied_status) %>: <%= setting_select :commit_update1_status_id, [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, :label => false %> |
|
76 |
<%= l(:field_done_ratio) %>: <%= setting_select :commit_update1_done_ratio, (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }, :blank => :label_no_change_option, :label => false %> |
|
77 |
<br /><em><%= l(:text_comma_separated) %></em></p> |
|
78 | ||
79 |
<p><%= setting_text_field :commit_update2_keywords, :size => 30 %> |
|
80 |
<%= l(:label_applied_status) %>: <%= setting_select :commit_update2_status_id, [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, :label => false %> |
|
81 |
<%= l(:field_done_ratio) %>: <%= setting_select :commit_update2_done_ratio, (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }, :blank => :label_no_change_option, :label => false %> |
|
82 |
<br /><em><%= l(:text_comma_separated) %></em></p> |
|
83 | ||
84 |
<p><%= setting_text_field :commit_update3_keywords, :size => 30 %> |
|
85 |
<%= l(:label_applied_status) %>: <%= setting_select :commit_update3_status_id, [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, :label => false %> |
|
86 |
<%= l(:field_done_ratio) %>: <%= setting_select :commit_update3_done_ratio, (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }, :blank => :label_no_change_option, :label => false %> |
|
87 |
<br /><em><%= l(:text_comma_separated) %></em></p> |
|
88 | ||
89 |
<p><%= setting_text_field :commit_update4_keywords, :size => 30 %> |
|
90 |
<%= l(:label_applied_status) %>: <%= setting_select :commit_update4_status_id, [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, :label => false %> |
|
91 |
<%= l(:field_done_ratio) %>: <%= setting_select :commit_update4_done_ratio, (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }, :blank => :label_no_change_option, :label => false %> |
|
92 |
<br /><em><%= l(:text_comma_separated) %></em></p> |
|
93 | ||
94 |
<p><%= setting_text_field :commit_update5_keywords, :size => 30 %> |
|
95 |
<%= l(:label_applied_status) %>: <%= setting_select :commit_update5_status_id, [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, :label => false %> |
|
96 |
<%= l(:field_done_ratio) %>: <%= setting_select :commit_update5_done_ratio, (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }, :blank => :label_no_change_option, :label => false %> |
|
97 | ||
98 | ||
99 | ||
83 | 100 |
<br /><em><%= l(:text_comma_separated) %></em></p> |
84 | 101 | |
85 | 102 |
<p><%= setting_check_box :commit_logtime_enabled, |
config/locales/en.yml | ||
---|---|---|
335 | 335 |
setting_autofetch_changesets: Autofetch commits |
336 | 336 |
setting_sys_api_enabled: Enable WS for repository management |
337 | 337 |
setting_commit_ref_keywords: Referencing keywords |
338 |
setting_commit_fix_keywords: Fixing keywords |
|
338 |
setting_commit_update1_keywords: Keywords |
|
339 |
setting_commit_update2_keywords: Keywords |
|
340 |
setting_commit_update3_keywords: Keywords |
|
341 |
setting_commit_update4_keywords: Keywords |
|
342 |
setting_commit_update5_keywords: Keywords |
|
339 | 343 |
setting_autologin: Autologin |
340 | 344 |
setting_date_format: Date format |
341 | 345 |
setting_time_format: Time format |
... | ... | |
902 | 906 |
text_unallowed_characters: Unallowed characters |
903 | 907 |
text_comma_separated: Multiple values allowed (comma separated). |
904 | 908 |
text_line_separated: Multiple values allowed (one line for each value). |
905 |
text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages
|
|
909 |
text_issues_ref_in_commit_messages: Referencing and updating issues in commit messages
|
|
906 | 910 |
text_issue_added: "Issue %{id} has been reported by %{author}." |
907 | 911 |
text_issue_updated: "Issue %{id} has been updated by %{author}." |
908 | 912 |
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content? |
config/settings.yml | ||
---|---|---|
92 | 92 |
default: 0 |
93 | 93 |
sys_api_key: |
94 | 94 |
default: '' |
95 |
# commit actions |
|
95 | 96 |
commit_ref_keywords: |
96 | 97 |
default: 'refs,references,IssueID' |
97 |
commit_fix_keywords: |
|
98 |
# commit update 1 |
|
99 |
commit_update1_keywords: |
|
98 | 100 |
default: 'fixes,closes' |
99 |
commit_fix_status_id:
|
|
101 |
commit_update1_status_id:
|
|
100 | 102 |
format: int |
101 | 103 |
default: 0 |
102 |
commit_fix_done_ratio: |
|
104 |
commit_update1_done_ratio: |
|
105 |
default: 100 |
|
106 |
# commit update 2 |
|
107 |
commit_update2_keywords: |
|
108 |
default: '' |
|
109 |
commit_update2_status_id: |
|
110 |
format: int |
|
111 |
default: 0 |
|
112 |
commit_update2_done_ratio: |
|
113 |
default: 100 |
|
114 |
# commit update 3 |
|
115 |
commit_update3_keywords: |
|
116 |
default: '' |
|
117 |
commit_update3_status_id: |
|
118 |
format: int |
|
119 |
default: 0 |
|
120 |
commit_update3_done_ratio: |
|
121 |
default: 100 |
|
122 |
# commitupdate 4 |
|
123 |
commit_update4_keywords: |
|
124 |
default: '' |
|
125 |
commit_update4_status_id: |
|
126 |
format: int |
|
127 |
default: 0 |
|
128 |
commit_update4_done_ratio: |
|
129 |
default: 100 |
|
130 |
# commit update 5 |
|
131 |
commit_update5_keywords: |
|
132 |
default: '' |
|
133 |
commit_update5_status_id: |
|
134 |
format: int |
|
135 |
default: 0 |
|
136 |
commit_update5_done_ratio: |
|
103 | 137 |
default: 100 |
104 | 138 |
commit_logtime_enabled: |
105 | 139 |
default: 0 |