Fix cloning for LinkedRepository coused by external_id uniqueness constraint [SCI-9879] (#7063)

This commit is contained in:
Alex Kriuchykhin 2024-02-06 12:59:21 +01:00 committed by GitHub
parent d5df5205ad
commit 8abc39d4f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 7 deletions

View file

@ -9,7 +9,7 @@ AllCops:
- "spec/**/*"
NewCops: enable
UseCache: false
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1
##################### Style ####################################

View file

@ -200,17 +200,13 @@ class Repository < RepositoryBase
fields
end
def copy(created_by, name)
def copy(created_by, new_name)
new_repo = nil
begin
Repository.transaction do
# Clone the repository object
new_repo = dup
new_repo.created_by = created_by
new_repo.name = name
new_repo.permission_level = Extends::SHARED_OBJECTS_PERMISSION_LEVELS[:not_shared]
new_repo.save!
new_repo = Repository.create!(name: new_name, team:, created_by:)
# Clone columns (only if new_repo was saved)
repository_columns.find_each do |col|