From 405a1a2deaceddf0a6f006559d6c5799f34b78f0 Mon Sep 17 00:00:00 2001 From: "vishal.s.patel" Date: Fri, 4 Jul 2025 15:00:43 +1200 Subject: [PATCH 1/6] Adding test seed file --- ee/db/seeds/data_seeder/vishal_seed.rb | 196 +++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 ee/db/seeds/data_seeder/vishal_seed.rb diff --git a/ee/db/seeds/data_seeder/vishal_seed.rb b/ee/db/seeds/data_seeder/vishal_seed.rb new file mode 100644 index 00000000000000..a4820cd424c435 --- /dev/null +++ b/ee/db/seeds/data_seeder/vishal_seed.rb @@ -0,0 +1,196 @@ +# frozen_string_literal: true + +class DataSeeder + def seed + # Step 1: Create user using factory + @user = create_user_with_factory + + # Step 2: Create group using factory + @group = create_group_with_factory + + # Step 3: Create project using factory (without :repository trait) + @project = create_project_with_factory + + # Step 4: Create repository manually + create_repository_for_project + + # Step 5: Create group labels using factories + create_group_labels_with_factories + + # Step 6: Create feature branch and merge request using factories + create_merge_request_with_factory + end + + private + + def create_user_with_factory + # Check if user already exists + existing_user = User.find_by(username: 'beautiful_dev') + return existing_user if existing_user + + # Create user using factory + create(:user, + name: 'Beautiful Developer', + username: 'beautiful_dev', + email: "beautiful_dev_#{SecureRandom.hex(8)}@example.com" + ) + end + + def create_group_with_factory + # Check if group already exists + existing_group = Group.find_by(path: 'beautiful-group') + return existing_group if existing_group + + # Create group using factory + group = create(:group, + name: 'Beautiful Group', + path: 'beautiful-group', + description: 'A beautiful group for testing', + visibility_level: Gitlab::VisibilityLevel::PRIVATE + ) + + # Add user as owner + group.add_owner(@user) + group + end + + def create_project_with_factory + # Check if project already exists + existing_project = @group.projects.find_by(path: 'beautiful-project') + return existing_project if existing_project + + # Create project using factory WITHOUT :repository trait + create(:project, + name: 'Beautiful Project', + path: 'beautiful-project', + namespace: @group, + description: 'A test project with dummy repository for seeding data', + visibility_level: Gitlab::VisibilityLevel::PRIVATE, + creator: @user + ) + end + + def create_repository_for_project + # Create repository manually if it doesn't exist + unless @project.repository_exists? + @project.create_repository + + # Add initial README file + @project.repository.create_file( + @user, + 'README.md', + "# #{@project.name}\n\nWelcome to the Beautiful Project!", + message: 'Initial commit', + branch_name: @project.default_branch || 'main' + ) + end + end + + def create_group_labels_with_factories + labels_data = [ + { title: 'priority::1', color: '#FF0000' }, + { title: 'priority::2', color: '#DD0000' }, + { title: 'priority::3', color: '#CC0000' }, + { title: 'priority::4', color: '#CC1111' } + ] + + labels_data.each do |label_data| + create_group_label_with_factory(label_data[:title], label_data[:color]) + end + end + + def create_group_label_with_factory(title, color) + # Check if label already exists + return if @group.labels.exists?(title: title) + + # Create group label using factory + create(:group_label, + group: @group, + title: title, + color: color + ) + end + + def create_merge_request_with_factory + # Check if MR already exists + existing_mr = @project.merge_requests.find_by( + source_branch: 'feature/beautiful-feature', + target_branch: @project.default_branch || 'main' + ) + return existing_mr if existing_mr + + # Create feature branch with changes + create_feature_branch_with_changes + + # Create merge request using factory + create(:merge_request, + title: 'Add beautiful feature implementation', + description: 'This MR adds a new beautiful feature with documentation and tests', + source_project: @project, + target_project: @project, + source_branch: 'feature/beautiful-feature', + target_branch: @project.default_branch || 'main', + author: @user + ) + end + + def create_feature_branch_with_changes + return if @project.repository.branch_exists?('feature/beautiful-feature') + + default_branch = @project.default_branch || 'main' + + # Create feature branch + @project.repository.create_branch('feature/beautiful-feature', default_branch) + + # Add files to the feature branch + files_to_create = [ + { + path: 'lib/beautiful_feature.rb', + content: <<~RUBY, + # frozen_string_literal: true + + class BeautifulFeature + def initialize(name) + @name = name + end + + def greet + "Hello, \#{@name}! This is a beautiful feature." + end + end + RUBY + message: 'Add BeautifulFeature class' + }, + { + path: 'spec/beautiful_feature_spec.rb', + content: <<~RUBY, + # frozen_string_literal: true + + require 'spec_helper' + + RSpec.describe BeautifulFeature do + describe '#greet' do + it 'returns a beautiful greeting' do + feature = BeautifulFeature.new('World') + expect(feature.greet).to eq('Hello, World! This is a beautiful feature.') + end + end + end + RUBY + message: 'Add tests for BeautifulFeature' + } + ] + + # Create each file in the feature branch + files_to_create.each do |file_data| + @project.repository.create_file( + @user, + file_data[:path], + file_data[:content], + message: file_data[:message], + branch_name: 'feature/beautiful-feature' + ) + end + end +end + -- GitLab From 9a94ad103fe2f1bed81fc0e3d3c301e2cc17ecca Mon Sep 17 00:00:00 2001 From: "vishal.s.patel" Date: Fri, 4 Jul 2025 15:51:20 +1200 Subject: [PATCH 2/6] Adding namespace cleanup code --- ee/db/seeds/data_seeder/vishal_seed.rb | 83 ++++++++++++++++---------- 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/ee/db/seeds/data_seeder/vishal_seed.rb b/ee/db/seeds/data_seeder/vishal_seed.rb index a4820cd424c435..5f59134d6edb7b 100644 --- a/ee/db/seeds/data_seeder/vishal_seed.rb +++ b/ee/db/seeds/data_seeder/vishal_seed.rb @@ -2,6 +2,9 @@ class DataSeeder def seed + # Clean up any orphaned CI namespace mirrors first + cleanup_orphaned_ci_mirrors + # Step 1: Create user using factory @user = create_user_with_factory @@ -23,29 +26,43 @@ def seed private + def cleanup_orphaned_ci_mirrors + # Find CI namespace mirrors that don't have corresponding namespaces + orphaned_mirrors = Ci::NamespaceMirror.joins("LEFT JOIN namespaces ON namespaces.id = ci_namespace_mirrors.namespace_id") + .where("namespaces.id IS NULL") + + if orphaned_mirrors.any? + puts "Cleaning up #{orphaned_mirrors.count} orphaned CI namespace mirrors..." + orphaned_mirrors.delete_all + end + end + def create_user_with_factory # Check if user already exists - existing_user = User.find_by(username: 'beautiful_dev') + existing_user = User.find_by(username: 'vishal_dev') return existing_user if existing_user - # Create user using factory + # Create user using factory with unique identifiers create(:user, - name: 'Beautiful Developer', - username: 'beautiful_dev', - email: "beautiful_dev_#{SecureRandom.hex(8)}@example.com" + name: 'Vishal Developer', + username: 'vishal_dev', + email: "vishal_dev_#{SecureRandom.hex(8)}@example.com" ) end def create_group_with_factory + # Use unique group path to avoid conflicts + group_path = "vishal-group-#{SecureRandom.hex(4)}" + # Check if group already exists - existing_group = Group.find_by(path: 'beautiful-group') + existing_group = Group.find_by(path: group_path) return existing_group if existing_group # Create group using factory group = create(:group, - name: 'Beautiful Group', - path: 'beautiful-group', - description: 'A beautiful group for testing', + name: 'Vishal Group', + path: group_path, + description: 'A group for Vishal testing', visibility_level: Gitlab::VisibilityLevel::PRIVATE ) @@ -55,16 +72,19 @@ def create_group_with_factory end def create_project_with_factory + # Use unique project path + project_path = "vishal-project-#{SecureRandom.hex(4)}" + # Check if project already exists - existing_project = @group.projects.find_by(path: 'beautiful-project') + existing_project = @group.projects.find_by(path: project_path) return existing_project if existing_project # Create project using factory WITHOUT :repository trait create(:project, - name: 'Beautiful Project', - path: 'beautiful-project', + name: 'Vishal Project', + path: project_path, namespace: @group, - description: 'A test project with dummy repository for seeding data', + description: 'A test project for Vishal with dummy repository', visibility_level: Gitlab::VisibilityLevel::PRIVATE, creator: @user ) @@ -79,7 +99,7 @@ def create_repository_for_project @project.repository.create_file( @user, 'README.md', - "# #{@project.name}\n\nWelcome to the Beautiful Project!", + "# #{@project.name}\n\nWelcome to Vishal's Project!", message: 'Initial commit', branch_name: @project.default_branch || 'main' ) @@ -114,7 +134,7 @@ def create_group_label_with_factory(title, color) def create_merge_request_with_factory # Check if MR already exists existing_mr = @project.merge_requests.find_by( - source_branch: 'feature/beautiful-feature', + source_branch: 'feature/vishal-feature', target_branch: @project.default_branch || 'main' ) return existing_mr if existing_mr @@ -124,60 +144,60 @@ def create_merge_request_with_factory # Create merge request using factory create(:merge_request, - title: 'Add beautiful feature implementation', - description: 'This MR adds a new beautiful feature with documentation and tests', + title: 'Add Vishal feature implementation', + description: 'This MR adds a new feature for Vishal with documentation and tests', source_project: @project, target_project: @project, - source_branch: 'feature/beautiful-feature', + source_branch: 'feature/vishal-feature', target_branch: @project.default_branch || 'main', author: @user ) end def create_feature_branch_with_changes - return if @project.repository.branch_exists?('feature/beautiful-feature') + return if @project.repository.branch_exists?('feature/vishal-feature') default_branch = @project.default_branch || 'main' # Create feature branch - @project.repository.create_branch('feature/beautiful-feature', default_branch) + @project.repository.create_branch('feature/vishal-feature', default_branch) # Add files to the feature branch files_to_create = [ { - path: 'lib/beautiful_feature.rb', + path: 'lib/vishal_feature.rb', content: <<~RUBY, # frozen_string_literal: true - class BeautifulFeature + class VishalFeature def initialize(name) @name = name end def greet - "Hello, \#{@name}! This is a beautiful feature." + "Hello, \#{@name}! This is Vishal's feature." end end RUBY - message: 'Add BeautifulFeature class' + message: 'Add VishalFeature class' }, { - path: 'spec/beautiful_feature_spec.rb', + path: 'spec/vishal_feature_spec.rb', content: <<~RUBY, # frozen_string_literal: true require 'spec_helper' - RSpec.describe BeautifulFeature do + RSpec.describe VishalFeature do describe '#greet' do - it 'returns a beautiful greeting' do - feature = BeautifulFeature.new('World') - expect(feature.greet).to eq('Hello, World! This is a beautiful feature.') + it 'returns a greeting from Vishal' do + feature = VishalFeature.new('World') + expect(feature.greet).to eq('Hello, World! This is Vishal\'s feature.') end end end RUBY - message: 'Add tests for BeautifulFeature' + message: 'Add tests for VishalFeature' } ] @@ -188,9 +208,8 @@ def greet file_data[:path], file_data[:content], message: file_data[:message], - branch_name: 'feature/beautiful-feature' + branch_name: 'feature/vishal-feature' ) end end end - -- GitLab From d84869ba08fe47f7994808e96609fa2b2f659d3a Mon Sep 17 00:00:00 2001 From: "vishal.s.patel" Date: Mon, 7 Jul 2025 11:07:04 +1200 Subject: [PATCH 3/6] Updating seed file --- ee/db/seeds/data_seeder/vishal_seed.rb | 42 +++++++++++--------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/ee/db/seeds/data_seeder/vishal_seed.rb b/ee/db/seeds/data_seeder/vishal_seed.rb index 5f59134d6edb7b..19b1100173ae52 100644 --- a/ee/db/seeds/data_seeder/vishal_seed.rb +++ b/ee/db/seeds/data_seeder/vishal_seed.rb @@ -51,24 +51,30 @@ def create_user_with_factory end def create_group_with_factory - # Use unique group path to avoid conflicts group_path = "vishal-group-#{SecureRandom.hex(4)}" - # Check if group already exists existing_group = Group.find_by(path: group_path) return existing_group if existing_group - # Create group using factory - group = create(:group, - name: 'Vishal Group', - path: group_path, - description: 'A group for Vishal testing', - visibility_level: Gitlab::VisibilityLevel::PRIVATE - ) + # Try to create the group + begin + group = create(:group, + name: 'Vishal Group', + path: group_path, + description: 'A group for Vishal testing', + visibility_level: Gitlab::VisibilityLevel::PRIVATE + ) - # Add user as owner - group.add_owner(@user) - group + group.add_owner(@user) + group + rescue ActiveRecord::RecordNotUnique => e + raise e unless e.message.include?('ci_namespace_mirrors') + + puts "CI namespace mirror already exists, retrying with different path..." + # Retry with a different path + group_path = "vishal-group-#{SecureRandom.hex(6)}" + retry + end end def create_project_with_factory @@ -119,18 +125,6 @@ def create_group_labels_with_factories end end - def create_group_label_with_factory(title, color) - # Check if label already exists - return if @group.labels.exists?(title: title) - - # Create group label using factory - create(:group_label, - group: @group, - title: title, - color: color - ) - end - def create_merge_request_with_factory # Check if MR already exists existing_mr = @project.merge_requests.find_by( -- GitLab From ddcc87ee7cea0f505863ec42ea0330c0959ce58a Mon Sep 17 00:00:00 2001 From: "vishal.s.patel" Date: Mon, 7 Jul 2025 12:02:38 +1200 Subject: [PATCH 4/6] Adding debugging --- ee/db/seeds/data_seeder/vishal_seed.rb | 33 ++++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/ee/db/seeds/data_seeder/vishal_seed.rb b/ee/db/seeds/data_seeder/vishal_seed.rb index 19b1100173ae52..a775e490d88da1 100644 --- a/ee/db/seeds/data_seeder/vishal_seed.rb +++ b/ee/db/seeds/data_seeder/vishal_seed.rb @@ -27,6 +27,7 @@ def seed private def cleanup_orphaned_ci_mirrors + puts "################### CLEANING UP ORPAHNED WITH FACTORY ###################" # Find CI namespace mirrors that don't have corresponding namespaces orphaned_mirrors = Ci::NamespaceMirror.joins("LEFT JOIN namespaces ON namespaces.id = ci_namespace_mirrors.namespace_id") .where("namespaces.id IS NULL") @@ -51,33 +52,26 @@ def create_user_with_factory end def create_group_with_factory + puts "################### CREATING THE GROUP WITH FACTORY ###################" group_path = "vishal-group-#{SecureRandom.hex(4)}" existing_group = Group.find_by(path: group_path) return existing_group if existing_group - # Try to create the group - begin - group = create(:group, - name: 'Vishal Group', - path: group_path, - description: 'A group for Vishal testing', - visibility_level: Gitlab::VisibilityLevel::PRIVATE - ) - - group.add_owner(@user) - group - rescue ActiveRecord::RecordNotUnique => e - raise e unless e.message.include?('ci_namespace_mirrors') + # Create group using factory but skip CI namespace mirror creation + group = create(:group, :without_ci_namespace_mirror, + name: 'Vishal Group', + path: group_path, + description: 'A group for Vishal testing', + visibility_level: Gitlab::VisibilityLevel::PRIVATE + ) - puts "CI namespace mirror already exists, retrying with different path..." - # Retry with a different path - group_path = "vishal-group-#{SecureRandom.hex(6)}" - retry - end + group.add_owner(@user) + group end def create_project_with_factory + puts "################### CREATING THE PROEJCT WITH FACTORY ###################" # Use unique project path project_path = "vishal-project-#{SecureRandom.hex(4)}" @@ -97,6 +91,7 @@ def create_project_with_factory end def create_repository_for_project + puts "################### CREATING THE REPOSITORY WITH FACTORY ###################" # Create repository manually if it doesn't exist unless @project.repository_exists? @project.create_repository @@ -113,6 +108,7 @@ def create_repository_for_project end def create_group_labels_with_factories + puts "################### CREATING THE GROUPLABELS WITH FACTORY ###################" labels_data = [ { title: 'priority::1', color: '#FF0000' }, { title: 'priority::2', color: '#DD0000' }, @@ -126,6 +122,7 @@ def create_group_labels_with_factories end def create_merge_request_with_factory + puts "################### CREATING THE MR WITH FACTORY ###################" # Check if MR already exists existing_mr = @project.merge_requests.find_by( source_branch: 'feature/vishal-feature', -- GitLab From f01cb8e31303240e42a3868ff875302c90236190 Mon Sep 17 00:00:00 2001 From: "vishal.s.patel" Date: Mon, 7 Jul 2025 13:00:40 +1200 Subject: [PATCH 5/6] Updated seed file --- ee/db/seeds/data_seeder/vishal_seed.rb | 45 ++++++++++++++------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/ee/db/seeds/data_seeder/vishal_seed.rb b/ee/db/seeds/data_seeder/vishal_seed.rb index a775e490d88da1..1183cc74e88b65 100644 --- a/ee/db/seeds/data_seeder/vishal_seed.rb +++ b/ee/db/seeds/data_seeder/vishal_seed.rb @@ -52,24 +52,33 @@ def create_user_with_factory end def create_group_with_factory - puts "################### CREATING THE GROUP WITH FACTORY ###################" - group_path = "vishal-group-#{SecureRandom.hex(4)}" - - existing_group = Group.find_by(path: group_path) - return existing_group if existing_group - - # Create group using factory but skip CI namespace mirror creation - group = create(:group, :without_ci_namespace_mirror, - name: 'Vishal Group', - path: group_path, - description: 'A group for Vishal testing', - visibility_level: Gitlab::VisibilityLevel::PRIVATE - ) - - group.add_owner(@user) - group + puts "################# CREATING THE GROUP WITH FACTORY ###################" + group_path = "vishal-group-#{SecureRandom.hex(4)}" + + existing_group = Group.find_by(path: group_path) + return existing_group if existing_group + + # Build the group without triggering callbacks, then save + group = build(:group, + name: 'Vishal Group', + path: group_path, + description: 'A group for Vishal testing', + visibility_level: Gitlab::VisibilityLevel::PRIVATE + ) + + # Save without triggering the CI namespace mirror callback + group.save!(validate: false) + + # Manually create CI namespace mirror if needed + unless Ci::NamespaceMirror.exists?(namespace_id: group.id) + Ci::NamespaceMirror.create!(namespace_id: group.id) end + group.add_owner(@user) + group +end + + def create_project_with_factory puts "################### CREATING THE PROEJCT WITH FACTORY ###################" # Use unique project path @@ -115,10 +124,6 @@ def create_group_labels_with_factories { title: 'priority::3', color: '#CC0000' }, { title: 'priority::4', color: '#CC1111' } ] - - labels_data.each do |label_data| - create_group_label_with_factory(label_data[:title], label_data[:color]) - end end def create_merge_request_with_factory -- GitLab From 564e45a9e41a93e1f4ac7192ba2da64d0c79b7c4 Mon Sep 17 00:00:00 2001 From: "vishal.s.patel" Date: Mon, 7 Jul 2025 15:46:08 +1200 Subject: [PATCH 6/6] Adding debugging --- ee/db/seeds/data_seeder/vishal_seed.rb | 98 ++++++++++++-------------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/ee/db/seeds/data_seeder/vishal_seed.rb b/ee/db/seeds/data_seeder/vishal_seed.rb index 1183cc74e88b65..6c8d18e90d2dbe 100644 --- a/ee/db/seeds/data_seeder/vishal_seed.rb +++ b/ee/db/seeds/data_seeder/vishal_seed.rb @@ -2,33 +2,35 @@ class DataSeeder def seed - # Clean up any orphaned CI namespace mirrors first + puts "################### CLEANING UP ORPHANED WITH FACTORY ###################" cleanup_orphaned_ci_mirrors - # Step 1: Create user using factory + puts "################### CREATING USER WITH FACTORY ###################" @user = create_user_with_factory - # Step 2: Create group using factory + puts "################### CREATING THE GROUP WITH FACTORY ###################" @group = create_group_with_factory - # Step 3: Create project using factory (without :repository trait) + puts "################### CREATING THE PROJECT WITH FACTORY ###################" @project = create_project_with_factory - # Step 4: Create repository manually + puts "################### CREATING THE REPOSITORY WITH FACTORY ###################" create_repository_for_project - # Step 5: Create group labels using factories + puts "################### CREATING THE GROUP LABELS WITH FACTORY ###################" create_group_labels_with_factories - # Step 6: Create feature branch and merge request using factories + puts "################### CREATING MERGE REQUEST WITH FACTORY ###################" create_merge_request_with_factory end private def cleanup_orphaned_ci_mirrors - puts "################### CLEANING UP ORPAHNED WITH FACTORY ###################" - # Find CI namespace mirrors that don't have corresponding namespaces + # Remove CI namespace mirror for namespace_id=2 specifically if it exists + Ci::NamespaceMirror.where(namespace_id: 2).delete_all + + # Also clean up any truly orphaned mirrors orphaned_mirrors = Ci::NamespaceMirror.joins("LEFT JOIN namespaces ON namespaces.id = ci_namespace_mirrors.namespace_id") .where("namespaces.id IS NULL") @@ -39,11 +41,9 @@ def cleanup_orphaned_ci_mirrors end def create_user_with_factory - # Check if user already exists existing_user = User.find_by(username: 'vishal_dev') return existing_user if existing_user - # Create user using factory with unique identifiers create(:user, name: 'Vishal Developer', username: 'vishal_dev', @@ -52,43 +52,37 @@ def create_user_with_factory end def create_group_with_factory - puts "################# CREATING THE GROUP WITH FACTORY ###################" - group_path = "vishal-group-#{SecureRandom.hex(4)}" - - existing_group = Group.find_by(path: group_path) - return existing_group if existing_group - - # Build the group without triggering callbacks, then save - group = build(:group, - name: 'Vishal Group', - path: group_path, - description: 'A group for Vishal testing', - visibility_level: Gitlab::VisibilityLevel::PRIVATE - ) - - # Save without triggering the CI namespace mirror callback - group.save!(validate: false) - - # Manually create CI namespace mirror if needed - unless Ci::NamespaceMirror.exists?(namespace_id: group.id) - Ci::NamespaceMirror.create!(namespace_id: group.id) - end + group_path = "vishal-group-#{SecureRandom.hex(4)}" - group.add_owner(@user) - group -end + existing_group = Group.find_by(path: group_path) + return existing_group if existing_group + + # Build the group without triggering callbacks, then save + group = build(:group, + name: 'Vishal Group', + path: group_path, + description: 'A group for Vishal testing', + visibility_level: Gitlab::VisibilityLevel::PRIVATE + ) + + # Save the group first + group.save! + + # Manually create CI namespace mirror if it doesn't exist + unless Ci::NamespaceMirror.exists?(namespace_id: group.id) + Ci::NamespaceMirror.create!(namespace_id: group.id) + end + group.add_owner(@user) + group + end def create_project_with_factory - puts "################### CREATING THE PROEJCT WITH FACTORY ###################" - # Use unique project path project_path = "vishal-project-#{SecureRandom.hex(4)}" - # Check if project already exists existing_project = @group.projects.find_by(path: project_path) return existing_project if existing_project - # Create project using factory WITHOUT :repository trait create(:project, name: 'Vishal Project', path: project_path, @@ -100,12 +94,9 @@ def create_project_with_factory end def create_repository_for_project - puts "################### CREATING THE REPOSITORY WITH FACTORY ###################" - # Create repository manually if it doesn't exist unless @project.repository_exists? @project.create_repository - # Add initial README file @project.repository.create_file( @user, 'README.md', @@ -117,28 +108,37 @@ def create_repository_for_project end def create_group_labels_with_factories - puts "################### CREATING THE GROUPLABELS WITH FACTORY ###################" labels_data = [ { title: 'priority::1', color: '#FF0000' }, { title: 'priority::2', color: '#DD0000' }, { title: 'priority::3', color: '#CC0000' }, { title: 'priority::4', color: '#CC1111' } ] + + labels_data.each do |label_data| + create_group_label_with_factory(label_data[:title], label_data[:color]) + end + end + + def create_group_label_with_factory(title, color) + return if @group.labels.exists?(title: title) + + create(:group_label, + group: @group, + title: title, + color: color + ) end def create_merge_request_with_factory - puts "################### CREATING THE MR WITH FACTORY ###################" - # Check if MR already exists existing_mr = @project.merge_requests.find_by( source_branch: 'feature/vishal-feature', target_branch: @project.default_branch || 'main' ) return existing_mr if existing_mr - # Create feature branch with changes create_feature_branch_with_changes - # Create merge request using factory create(:merge_request, title: 'Add Vishal feature implementation', description: 'This MR adds a new feature for Vishal with documentation and tests', @@ -154,11 +154,8 @@ def create_feature_branch_with_changes return if @project.repository.branch_exists?('feature/vishal-feature') default_branch = @project.default_branch || 'main' - - # Create feature branch @project.repository.create_branch('feature/vishal-feature', default_branch) - # Add files to the feature branch files_to_create = [ { path: 'lib/vishal_feature.rb', @@ -197,7 +194,6 @@ def greet } ] - # Create each file in the feature branch files_to_create.each do |file_data| @project.repository.create_file( @user, -- GitLab