diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-26 12:09:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-26 12:09:00 +0300 |
commit | ec3483bd1831dfca0c7baec0f8aad9079d28907d (patch) | |
tree | 67b6f8eed91c44ab4054191d2a2fbf9d18cc695e /app/models/remote_mirror.rb | |
parent | d10e03ba6f8d5d425e53931d306a099404a5958b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/remote_mirror.rb')
-rw-r--r-- | app/models/remote_mirror.rb | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/app/models/remote_mirror.rb b/app/models/remote_mirror.rb index a700f104150..4937f2e862b 100644 --- a/app/models/remote_mirror.rb +++ b/app/models/remote_mirror.rb @@ -25,11 +25,8 @@ class RemoteMirror < ApplicationRecord before_save :set_new_remote_name, if: :mirror_url_changed? after_save :set_override_remote_mirror_available, unless: -> { Gitlab::CurrentSettings.current_application_settings.mirror_available } - after_save :refresh_remote, if: :saved_change_to_mirror_url? after_update :reset_fields, if: :saved_change_to_mirror_url? - after_commit :remove_remote, on: :destroy - before_validation :store_credentials scope :enabled, -> { where(enabled: true) } @@ -100,11 +97,11 @@ class RemoteMirror < ApplicationRecord update_status == 'started' end - def update_repository(inmemory_remote:) + def update_repository Gitlab::Git::RemoteMirror.new( project.repository.raw, remote_name, - inmemory_remote ? remote_url : nil, + remote_url, **options_for_update ).update end @@ -227,15 +224,6 @@ class RemoteMirror < ApplicationRecord Gitlab::UrlSanitizer.new(read_attribute(:url)).full_url end - def ensure_remote! - return unless project - return unless remote_name && remote_url - - # If this fails or the remote already exists, we won't know due to - # https://gitlab.com/gitlab-org/gitaly/issues/1317 - project.repository.add_remote(remote_name, remote_url) - end - def after_sent_notification update_column(:error_notification_sent, true) end @@ -312,25 +300,6 @@ class RemoteMirror < ApplicationRecord self.remote_name = "remote_mirror_#{SecureRandom.hex}" end - def refresh_remote - return unless project - - # Before adding a new remote we have to delete the data from - # the previous remote name - prev_remote_name = remote_name_before_last_save || fallback_remote_name - run_after_commit do - project.repository.async_remove_remote(prev_remote_name) - end - - project.repository.add_remote(remote_name, remote_url) - end - - def remove_remote - return unless project # could be pending to delete so don't need to touch the git repository - - project.repository.async_remove_remote(remote_name) - end - def mirror_url_changed? url_changed? || attribute_changed?(:credentials) end |