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
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-09-23 13:47:29 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2015-09-30 13:48:40 +0300
commitb9ccc79cb5d67e356edce3778b6a17def985ed22 (patch)
tree103aacc1d621c7d6436c2ad3a2a52d48dfc395e1 /app/models
parent34431d8ecb1c3d3082c3e391db70b33ca7dbf056 (diff)
Delegate ci_project parameters to projects
- It delegates name, path, gitlab_url, ssh_url_to_repo - Remove ability to set this parameters using CI API This fixes GitLab project rename, namespace change, repository rename, etc.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/project.rb40
-rw-r--r--app/models/project_services/gitlab_ci_service.rb6
2 files changed, 19 insertions, 27 deletions
diff --git a/app/models/ci/project.rb b/app/models/ci/project.rb
index 77cce261fc8..f0a8fc703b5 100644
--- a/app/models/ci/project.rb
+++ b/app/models/ci/project.rb
@@ -48,11 +48,12 @@ module Ci
accepts_nested_attributes_for :variables, allow_destroy: true
+ delegate :name_with_namespace, :path_with_namespace, :web_url, :http_url_to_repo, :ssh_url_to_repo, to: :gl_project
+
#
# Validations
#
- validates_presence_of :name, :timeout, :token, :default_ref,
- :path, :ssh_url_to_repo, :gitlab_id
+ validates_presence_of :timeout, :token, :default_ref, :gitlab_id
validates_uniqueness_of :gitlab_id
@@ -60,8 +61,6 @@ module Ci
presence: true,
if: ->(project) { project.always_build.present? }
- scope :public_only, ->() { where(public: true) }
-
before_validation :set_default_values
class << self
@@ -76,12 +75,9 @@ module Ci
def parse(project)
params = {
- name: project.name_with_namespace,
- gitlab_id: project.id,
- path: project.path_with_namespace,
- default_ref: project.default_branch || 'master',
- ssh_url_to_repo: project.ssh_url_to_repo,
- email_add_pusher: current_application_settings.add_pusher,
+ gitlab_id: project.id,
+ default_ref: project.default_branch || 'master',
+ email_add_pusher: current_application_settings.add_pusher,
email_only_broken_builds: current_application_settings.all_broken_builds,
}
@@ -105,11 +101,18 @@ module Ci
joins("LEFT JOIN #{last_commit_subquery} AS last_commit ON #{Ci::Project.table_name}.gitlab_id = last_commit.gl_project_id").
order("CASE WHEN last_commit.committed_at IS NULL THEN 1 ELSE 0 END, last_commit.committed_at DESC")
end
+ end
- def search(query)
- where("LOWER(#{Ci::Project.table_name}.name) LIKE :query",
- query: "%#{query.try(:downcase)}%")
- end
+ def name
+ name_with_namespace
+ end
+
+ def path
+ path_with_namespace
+ end
+
+ def gitlab_url
+ web_url
end
def any_runners?
@@ -123,9 +126,6 @@ module Ci
def set_default_values
self.token = SecureRandom.hex(15) if self.token.blank?
self.default_ref ||= 'master'
- self.name ||= gl_project.name_with_namespace
- self.path ||= gl_project.path_with_namespace
- self.ssh_url_to_repo ||= gl_project.ssh_url_to_repo
end
def tracked_refs
@@ -169,7 +169,7 @@ module Ci
# using http and basic auth
def repo_url_with_auth
auth = "gitlab-ci-token:#{token}@"
- url = gitlab_url + ".git"
+ url = http_url_to_repo + ".git"
url.sub(/^https?:\/\//) do |prefix|
prefix + auth
end
@@ -201,10 +201,6 @@ module Ci
end
end
- def gitlab_url
- File.join(Gitlab.config.gitlab.url, path)
- end
-
def setup_finished?
commits.any?
end
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index 23ab206efba..436d4cfed81 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -70,11 +70,7 @@ class GitlabCiService < CiService
def fork_registration(new_project, current_user)
params = OpenStruct.new({
id: new_project.id,
- name_with_namespace: new_project.name_with_namespace,
- path_with_namespace: new_project.path_with_namespace,
- web_url: new_project.web_url,
- default_branch: new_project.default_branch,
- ssh_url_to_repo: new_project.ssh_url_to_repo
+ default_branch: new_project.default_branch
})
ci_project = Ci::Project.find_by!(gitlab_id: project.id)