Skip to content

Add project setting to disable merge immediately [RUN ALL RSPEC] [RUN AS-IF-FOSS]

What does this MR do?

This is behind a feature flag and implements parts of #320981 (closed). Which adds an admin-only project setting that when disabled will prevent users from bypassing pipeline completion and merging.

What's included in the MR:

  • Adds a migration with the new column (true by default)
  • Allows for updating the new column (controller and view)
  • Feature test for updating the column
  • Blocks Merging via API if merge_when_pipeline_succeeds is false and the new column is set to false

What's not included in this MR:

  • Graphql update
  • Graphql fetch
  • Public REST Api update
  • Public REST Api fetch
  • Disabling merge immediately button based on the new column

Screenshots (strongly suggested)

Screen_Shot_2021-05-13_at_10.20.06_AM

Database

Migration

Up

== 20210216153814 AddMergeBeforePipelineSucceedsToCiCdSettings: migrating =====
-- add_column(:project_ci_cd_settings, :merge_before_pipeline_completes_enabled, :boolean, {:default=>true, :null=>false})
   -> 0.0030s
== 20210216153814 AddMergeBeforePipelineSucceedsToCiCdSettings: migrated (0.0122s)
ALTER TABLE "project_ci_cd_settings" ADD "merge_before_pipeline_completes_enabled" boolean DEFAULT TRUE NOT NULL

Down

rake db:migrate:down VERSION=20210216153814
== 20210216153814 AddMergeBeforePipelineSucceedsToCiCdSettings: reverting =====
-- remove_column(:project_ci_cd_settings, :merge_before_pipeline_completes_enabled)
   -> 0.0047s
== 20210216153814 AddMergeBeforePipelineSucceedsToCiCdSettings: reverted (0.0117s)
ALTER TABLE "project_ci_cd_settings" DROP COLUMN "merge_before_pipeline_completes_enabled"

Queries

UPDATE "project_ci_cd_settings" 
SET "merge_before_pipeline_completes_enabled" = TRUE 
WHERE "project_ci_cd_settings"."id" = 36;
Time: 22.323 ms
  - planning: 0.591 ms
  - execution: 21.732 ms
    - I/O read: 21.380 ms
    - I/O write: N/A

Shared buffers:
  - hits: 8 (~64.00 KiB) from the buffer pool
  - reads: 15 (~120.00 KiB) from the OS file cache, including disk I/O
  - dirtied: 5 (~40.00 KiB)
  - writes: 0

https://console.postgres.ai/gitlab/gitlab-production-tunnel/sessions/3982/commands/13717

Conformity

Queries

 UPDATE "project_ci_cd_settings" SET "merge_before_pipeline_completes_enabled" = TRUE

Availability and Testing

Edited by Allison Browne

Merge request reports

Loading