Skip to content

Add setting to change default MR target project

What does this MR do?

  1. Adds project_settings.mr_default_target_self column
  2. Adds UI to allow user to set project_settings.mr_default_target_self
  3. If project_settings.mr_default_target_self is true we use same project as default target for a new merge request. Otherwise we use old behavior where upstream project was used.

Related to #14522 (closed)

Database migration output:

Up

[2] pry(main)> require './db/migrate/20210331125111_add_default_target_project.rb'
=> true
[3] pry(main)> AddDefaultTargetProject.new.up
   (0.2ms)  BEGIN /*application:console,line:/lib/gitlab/database/with_lock_retries.rb:168:in `execute'*/
   (0.1ms)  SET LOCAL lock_timeout TO '100ms' /*application:console,line:/lib/gitlab/database/with_lock_retries.rb:168:in `execute'*/
-- add_column(:project_settings, :mr_default_target_self, :boolean, {:default=>false, :null=>false})
   (0.7ms)  ALTER TABLE "project_settings" ADD "mr_default_target_self" boolean DEFAULT FALSE NOT NULL /*application:console,line:/Users/dzaporozhets/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/benchmark.rb:293:in `measure'*/
   -> 0.0018s
   (5.9ms)  COMMIT /*application:console,line:/lib/gitlab/database.rb:342:in `block in transaction'*/
   (0.2ms)  RESET idle_in_transaction_session_timeout; RESET lock_timeout /*application:console,line:/lib/gitlab/database/with_lock_retries.rb:168:in `execute'*/
=> true

Down

[1] pry(main)> require './db/migrate/20210331125111_add_default_target_project.rb'
=> true
[2] pry(main)> AddDefaultTargetProject.new.down
   (0.4ms)  BEGIN /*application:console,line:/lib/gitlab/database/with_lock_retries.rb:168:in `execute'*/
   (0.2ms)  SET LOCAL lock_timeout TO '100ms' /*application:console,line:/lib/gitlab/database/with_lock_retries.rb:168:in `execute'*/
-- remove_column(:project_settings, :mr_default_target_self)
   (0.9ms)  ALTER TABLE "project_settings" DROP COLUMN "mr_default_target_self" /*application:console,line:/Users/dzaporozhets/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0/benchmark.rb:293:in `measure'*/
   -> 0.0014s
   (0.5ms)  COMMIT /*application:console,line:/lib/gitlab/database.rb:342:in `block in transaction'*/
   (0.1ms)  RESET idle_in_transaction_session_timeout; RESET lock_timeout /*application:console,line:/lib/gitlab/database/with_lock_retries.rb:168:in `execute'*/
=> true

Screenshots (strongly suggested)

Project settings

Screenshot_2021-04-07_at_16.22.51

When user choose "this project"

Screenshot_2021-03-31_at_17.37.48

When user choose "upstream project"

Screenshot_2021-03-31_at_17.31.13

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Dmytro Zaporozhets (DZ)

Merge request reports