Commit 3c9b4da8 authored by Douwe Maan's avatar Douwe Maan

Allow project to be set up to push to and pull from same mirror

parent ff0fafe3
---
title: Allow project to be set up to push to and pull from same mirror
merge_request:
author:
type: fixed
...@@ -334,12 +334,6 @@ module EE ...@@ -334,12 +334,6 @@ module EE
repository.async_remove_remote(::Repository::MIRROR_REMOTE) repository.async_remove_remote(::Repository::MIRROR_REMOTE)
end end
def import_url_availability
if remote_mirrors.find_by(url: import_url)
errors.add(:import_url, 'is already in use by a remote mirror')
end
end
def username_only_import_url def username_only_import_url
bare_url = read_attribute(:import_url) bare_url = read_attribute(:import_url)
return bare_url unless ::Gitlab::UrlSanitizer.valid?(bare_url) return bare_url unless ::Gitlab::UrlSanitizer.valid?(bare_url)
......
...@@ -17,8 +17,6 @@ class RemoteMirror < ActiveRecord::Base ...@@ -17,8 +17,6 @@ class RemoteMirror < ActiveRecord::Base
belongs_to :project, inverse_of: :remote_mirrors belongs_to :project, inverse_of: :remote_mirrors
validates :url, presence: true, url: { protocols: %w(ssh git http https), allow_blank: true } validates :url, presence: true, url: { protocols: %w(ssh git http https), allow_blank: true }
validate :url_availability, if: -> (mirror) { mirror.url_changed? || mirror.enabled? }
validates :url, addressable_url: true, if: :url_changed? validates :url, addressable_url: true, if: :url_changed?
before_save :set_new_remote_name, if: :mirror_url_changed? before_save :set_new_remote_name, if: :mirror_url_changed?
...@@ -174,14 +172,6 @@ class RemoteMirror < ActiveRecord::Base ...@@ -174,14 +172,6 @@ class RemoteMirror < ActiveRecord::Base
end end
end end
def url_availability
return unless project
if project.import_url == url && project.mirror?
errors.add(:url, 'is already in use')
end
end
def reset_fields def reset_fields
update_columns( update_columns(
last_error: nil, last_error: nil,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment