File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ One of the following environment variables need to be set:
4141They must contain secrets which have to be configured in GitLab/GitHub to
4242authenticate webhooks.
4343
44+ Optionally, you can also set the following variables:
45+
46+ * ` REDMINE_MERGE_REQUEST_LINKS_AFTER_MERGE_STATUS ` - Name of issue status which should be set after the merge request is merged.
47+ * ` REDMINE_MERGE_REQUEST_LINKS_GITLAB_REDMINE_USER_ID ` - ID of Redmine user who should change the status - used as journal author.
48+
4449Export the environment variable(s) in your bash or webserver config.
4550Examples with Phusion Passenger webserver can be found here:
4651https://www.phusionpassenger.com/library/indepth/environment_variables.html
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class MergeRequest < ActiveRecord::Base
1010 # update the author name only once.
1111 attr_readonly :author_name
1212
13- after_save :scan_description_for_issue_ids
13+ after_save :scan_description_for_issue_ids , :update_mentioned_issues_status
1414
1515 def self . find_all_by_issue ( issue )
1616 includes ( :issues ) . where ( issues : { id : issue . id } )
@@ -31,4 +31,22 @@ def mentioned_issue_ids
3131 ( value || '' ) . scan ( ISSUE_ID_REGEXP )
3232 end . uniq
3333 end
34+
35+ def update_mentioned_issues_status
36+ redmine_user_id = ENV [ 'REDMINE_MERGE_REQUEST_LINKS_GITLAB_REDMINE_USER_ID' ]
37+ after_merge_status = ENV [ 'REDMINE_MERGE_REQUEST_LINKS_AFTER_MERGE_STATUS' ]
38+
39+ if state != 'merged' || redmine_user_id . blank? || after_merge_status . blank?
40+ return
41+ end
42+
43+ mentioned_issue_ids . map do |match |
44+ issue = Issue . find_by_id ( match [ 0 ] )
45+ if issue . present?
46+ issue . init_journal ( User . find ( redmine_user_id ) )
47+ issue . status = IssueStatus . find_by_name ( after_merge_status )
48+ issue . save!
49+ end
50+ end
51+ end
3452end
You can’t perform that action at this time.
0 commit comments