Feature #4199
Reassign back to original author from an SCM commit
Status: | Closed | Start date: | 2009-11-12 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | - | % Done: | 0% | |
Category: | SCM | |||
Target version: | - | |||
Resolution: | Wont fix |
Description
We've got a post-commit hook going at work (the same as the one in the wiki) and it works great. One thing we wanted was that if we noted a revision as fixing an issue, it should not only just set it to a specific status, but also to reassign it back to the original author.
So I went in an hacked it together and I believe it works; however, I can't say it's the most efficient way to do it. Perhaps the only thing missing is a config flag of "Reassign to author on verify & close?" in the section with the fixes keywords.
Here's the code:
issue.done_ratio = done_ratio if done_ratio
# Reassign back to original author, or default to nobody
reassign_to = nil
issue.assignable_users.each do |assignuser|
reassign_to = assignuser if assignuser.id == issue.author_id
end
issue.assigned_to = reassign_to
# End reassign to original author
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
{ :changeset => self, :issue => issue })
issue.save
This goes in app/models/changeset.rb right around line 114.
Thoughts on adding this in to 0.8.7?
Related issues
Associated revisions
Allow assigning issues back to the author. #4199
This allows an issue to be reassigned to the author even if they are not
a project member. Useful when passing back an issue to get more
information from the author.
History
#1
Updated by Eric Davis almost 13 years ago
- Priority changed from High to Normal
- Estimated time deleted (
2.00)
Could you upload this as a patch file?
#2
Updated by Brett Patterson almost 13 years ago
- File reassign_to_author.patch
added
Here's your patch file:
Index: app/models/changeset.rb =================================================================== --- app/models/changeset.rb (revision 3033) +++ app/models/changeset.rb (working copy) @@ -112,6 +112,11 @@ journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext)) issue.status = fix_status issue.done_ratio = done_ratio if done_ratio + reassign_to = nil + issue.assignable_users.each do |assignuser| + reassign_to = assignuser if assignuser.id == issue.author_id + end + issue.assigned_to = reassign_to Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update, { :changeset => self, :issue => issue }) issue.save
#3
Updated by Brett Patterson over 12 years ago
Any update or thoughts on this making it's way into a release?
#4
Updated by Brett Patterson over 12 years ago
The same patch above can be applied to 1.9
#5
Updated by Brett Patterson almost 12 years ago
Can still be applied to 1.0.1, the line numbers change just a little bit. New code reference is:
unless Setting.commit_fix_done_ratio.blank?
issue.done_ratio = Setting.commit_fix_done_ratio.to_i
reassign_to = nil
issue.assignable_users.each do |assignuser|
reassign_to = assignuser if assignuser.id == issue.author_id
issue.assigned_to = reassign_to
end
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
{ :changeset => self, :issue => issue })
Should be about line 117.
#6
Updated by Brett Patterson almost 12 years ago
Code fix... Now showing lines 117 - 130 of app/models/changeset.rb
unless Setting.commit_fix_done_ratio.blank?
issue.done_ratio = Setting.commit_fix_done_ratio.to_i
end
# Reassign to original author if it's different
reassign_to = nil
issue.assignable_users.each do |assignuser|
reassign_to = assignuser if assignuser.id == issue.author_id
end
issue.assigned_to = reassign_to if reassign_to != nil
# End Reassign to original author
Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update,
{ :changeset => self, :issue => issue })
#7
Updated by Eric Davis almost 12 years ago
- Subject changed from Reassign back to original author to Reassign back to original author from an SCM commit
- Status changed from New to Closed
- Resolution set to Wont fix
Brett Patterson:
Thanks for the patches but I don't want to include these in the Redmine core. This is too specific of a workflow and not general enough for everyone who uses Redmine.
You can easily convert your patch to a plugin and use that hook below to do the same thing though (the :model_changeset_scan_commit_for_issue_ids_pre_issue_update
hook).
#8
Updated by Brett Patterson almost 12 years ago
Thanks for the update. I'll see if I can convert it to a plugin successfully.
#9
Updated by Eric Davis almost 12 years ago
Let me know if you get stuck. I follow most posts in the Plugin forum.
#10
Updated by Go MAEDA 8 months ago
- Related to Defect #36368: show in assignable user when he/she is not member of that project added