Skip to content

Add setting to not display code diffs in MR review emails

Joe Snyder requested to merge joe-snyder/gitlab:prevent_diff_in_email into master

What does this MR do and why?

This merge requests adds a new setting to the "General" page of an individual project. When the setting is toggled on, the code diffs which would normally be sent in the email about a review will be hidden. This prevents a potential avenue of sensitive code reaching unintended recipients.

Fixes #24733 (closed)

Screenshots or screen recordings

Toggled Off: image

Resulting Email: image

Toggled On (default):

image

Resulting Email: image

DB Interactions

Migration:

gitlab$ bin/rails db:migrate
== 20220131192643 AddShowDiffPreviewInEmailToProjectSettings: migrating =======
-- add_column(:project_settings, :show_diff_preview_in_email, :boolean, {:default=>true, :null=>false})
   -> 0.0023s
== 20220131192643 AddShowDiffPreviewInEmailToProjectSettings: migrated (0.0024s) 

Rollback:

bin/rails db:rollback
== 20220131192643 AddShowDiffPreviewInEmailToProjectSettings: reverting =======
-- remove_column(:project_settings, :show_diff_preview_in_email, :boolean, {:default=>true, :null=>false})
   -> 0.0017s
== 20220131192643 AddShowDiffPreviewInEmailToProjectSettings: reverted (0.0032s) 

How to set up and validate locally

  1. Check out the branch
  2. Generate merge request with diff.
  3. Comment on specific line, see that HTML/text diff is in the resulting email
  4. Toggle setting, save
  5. Comment on another line, see that the HTML/text diff is not in the resulting email

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Joe Snyder

Merge request reports