Skip to content

Merge Request auto close issues now checked on merge

Mario Celi requested to merge 468223-check-project-setting-on-merge into master

What does this MR do and why?

Before we would not create merge_requests_closing_issues in the DB if the referenced issues's project had autoclose_referenced_issues disabled. Now we create the records in the DB even if it is disabled, but we check that the setting is enabled on the project before closing each issue when the MR is merged.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Before this MR

  1. Disable the project setting in Settings -> Repository -> Branch defaults -> Auto-close referenced issues on default branch
  2. Use the closing pattern in a merge request description. Like Closes #2 where 2 is the IID of an open issue.
  3. In the rails console check that a record was not created MergeRequestsClosingIssues.last
  4. Enable the project setting in Settings -> Repository -> Branch defaults -> Auto-close referenced issues on default branch
  5. Update the MR's description to something different (you can simply append something to the existing closing pattern)
  6. In the rails console check that a record was created MergeRequestsClosingIssues.last
  7. Disable the project setting in Settings -> Repository -> Branch defaults -> Auto-close referenced issues on default branch
  8. Merge the merge request and issue #2 will be closed anyway

After this MR

  1. Disable the project setting in Settings -> Repository -> Branch defaults -> Auto-close referenced issues on default branch
  2. Use the closing pattern in a merge request description. Like Closes #2 where 2 is the IID of an open issue.
  3. In the rails console check that a record was created MergeRequestsClosingIssues.last
  4. Merge the merge request and issue #2 wont be closed because the setting is disabled

Related to #468223

Edited by Mario Celi

Merge request reports