Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-10-16 03:09:27 +0300
committerStan Hu <stanhu@gmail.com>2018-10-16 03:09:27 +0300
commitc09de611ea9d8cbff7a1696ee63262ef65972daa (patch)
tree13f9af851fdf29c53256abdeaf954d6f5d512c56 /app
parenta88004c876b94d44ce61c19d8c4c42e8de636f58 (diff)
parent2e75e93c31848df37cb85043cc440ed8e1cce28b (diff)
Merge branch 'da-fix-does-not-import-projects-over-ssh' into 'master'
Does not allow a SSH URI when importing a project See merge request gitlab-org/gitlab-ce!22309
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index c7ca322853f..b80e41e4a96 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -49,8 +49,11 @@ class Project < ActiveRecord::Base
attachments: 2
}.freeze
- # Valids ports to import from
- VALID_IMPORT_PORTS = [22, 80, 443].freeze
+ VALID_IMPORT_PORTS = [80, 443].freeze
+ VALID_IMPORT_PROTOCOLS = %w(http https git).freeze
+
+ VALID_MIRROR_PORTS = [22, 80, 443].freeze
+ VALID_MIRROR_PROTOCOLS = %w(http https ssh git).freeze
cache_markdown_field :description, pipeline: :description
@@ -305,10 +308,10 @@ class Project < ActiveRecord::Base
validates :namespace, presence: true
validates :name, uniqueness: { scope: :namespace_id }
- validates :import_url, url: { protocols: %w(http https ssh git),
+ validates :import_url, url: { protocols: ->(project) { project.persisted? ? VALID_MIRROR_PROTOCOLS : VALID_IMPORT_PROTOCOLS },
+ ports: ->(project) { project.persisted? ? VALID_MIRROR_PORTS : VALID_IMPORT_PORTS },
allow_localhost: false,
- enforce_user: true,
- ports: VALID_IMPORT_PORTS }, if: [:external_import?, :import_url_changed?]
+ enforce_user: true }, if: [:external_import?, :import_url_changed?]
validates :star_count, numericality: { greater_than_or_equal_to: 0 }
validate :check_limit, on: :create
validate :check_repository_path_availability, on: :update, if: ->(project) { project.renamed? }