Defect #4163 » patch-cp-issue-keywords_2.diff
app/controllers/issues_controller.rb | ||
---|---|---|
117 | 117 |
@changesets = @issue.changesets |
118 | 118 |
@changesets.reverse! if User.current.wants_comments_in_reverse_order? |
119 | 119 |
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
120 |
@allowed_changesets = @issue.changesets.select do |changeset| |
|
121 |
User.current.allowed_to?(:view_changesets, changeset.project) |
|
122 |
end |
|
120 | 123 |
@edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
121 | 124 |
@priorities = IssuePriority.all |
122 | 125 |
@time_entry = TimeEntry.new |
app/models/changeset.rb | ||
---|---|---|
80 | 80 |
# status and optional done ratio applied |
81 | 81 |
fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id) |
82 | 82 |
done_ratio = Setting.commit_fix_done_ratio.blank? ? nil : Setting.commit_fix_done_ratio.to_i |
83 |
if Setting.cross_project_commit_keywords? |
|
84 |
issues_finder = Issue |
|
85 |
else |
|
86 |
issues_finder = repository.project.issues |
|
87 |
end |
|
83 | 88 |
|
84 | 89 |
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw)}.join("|") |
85 | 90 |
return if kw_regexp.blank? |
... | ... | |
90 | 95 |
# find any issue ID in the comments |
91 | 96 |
target_issue_ids = [] |
92 | 97 |
comments.scan(%r{([\s\(\[,-]|^)#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] } |
93 |
referenced_issues += repository.project.issues.find_all_by_id(target_issue_ids)
|
|
98 |
referenced_issues += issues_finder.find_all_by_id(target_issue_ids)
|
|
94 | 99 |
end |
95 | 100 |
|
96 | 101 |
comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match| |
97 | 102 |
action = match[0] |
98 | 103 |
target_issue_ids = match[1].scan(/\d+/) |
99 |
target_issues = repository.project.issues.find_all_by_id(target_issue_ids)
|
|
104 |
target_issues = issues_finder.find_all_by_id(target_issue_ids)
|
|
100 | 105 |
if fix_status && fix_keywords.include?(action.downcase) |
101 | 106 |
# update status of issues |
102 | 107 |
logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug? |
app/views/issues/show.rhtml | ||
---|---|---|
80 | 80 | |
81 | 81 |
</div> |
82 | 82 | |
83 |
<% if @changesets.any? && User.current.allowed_to?(:view_changesets, @project) %>
|
|
83 |
<% if @allowed_changesets.any? %>
|
|
84 | 84 |
<div id="issue-changesets"> |
85 | 85 |
<h3><%=l(:label_associated_revisions)%></h3> |
86 |
<%= render :partial => 'changesets', :locals => { :changesets => @changesets} %> |
|
86 |
<%= render :partial => 'changesets', :locals => { :changesets => @allowed_changesets} %>
|
|
87 | 87 |
</div> |
88 | 88 |
<% end %> |
89 | 89 |
app/views/settings/_repositories.rhtml | ||
---|---|---|
11 | 11 |
<%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %> |
12 | 12 |
</p> |
13 | 13 | |
14 |
<p><label><%= l(:setting_cross_project_commit_keywords) %></label> |
|
15 |
<%= hidden_field_tag 'settings[cross_project_commit_keywords]', 0 %> |
|
16 |
<%= check_box_tag 'settings[cross_project_commit_keywords]', 1, Setting.cross_project_commit_keywords? %> |
|
17 |
</p> |
|
18 | ||
14 | 19 |
<p><label><%= l(:setting_enabled_scm) %></label> |
15 | 20 |
<% REDMINE_SUPPORTED_SCM.each do |scm| -%> |
16 | 21 |
<%= check_box_tag 'settings[enabled_scm][]', scm, Setting.enabled_scm.include?(scm) %> <%= scm %> |
config/locales/en.yml | ||
---|---|---|
285 | 285 |
setting_default_projects_public: New projects are public by default |
286 | 286 |
setting_autofetch_changesets: Autofetch commits |
287 | 287 |
setting_sys_api_enabled: Enable WS for repository management |
288 |
setting_cross_project_commit_keywords: Allow cross project references in commit messages |
|
288 | 289 |
setting_commit_ref_keywords: Referencing keywords |
289 | 290 |
setting_commit_fix_keywords: Fixing keywords |
290 | 291 |
setting_autologin: Autologin |
config/settings.yml | ||
---|---|---|
94 | 94 |
default: 0 |
95 | 95 |
commit_fix_done_ratio: |
96 | 96 |
default: 100 |
97 |
cross_project_commit_keywords: |
|
98 |
default: 0 |
|
97 | 99 |
# autologin duration in days |
98 | 100 |
# 0 means autologin is disabled |
99 | 101 |
autologin: |
test/unit/repository_test.rb | ||
---|---|---|
104 | 104 |
|
105 | 105 |
# ignoring commits referencing an issue of another project |
106 | 106 |
assert_equal [], Issue.find(4).changesets |
107 |
Setting.cross_project_commit_keywords = 1 |
|
108 |
Repository.scan_changesets_for_issue_ids |
|
109 |
assert_equal [103], Issue.find(4).changeset_ids |
|
107 | 110 |
end |
108 | 111 |
|
109 | 112 |
def test_for_changeset_comments_strip |
- « Previous
- 1
- 2
- Next »