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:
authorDouwe Maan <douwe@gitlab.com>2015-10-01 13:34:32 +0300
committerDouwe Maan <douwe@gitlab.com>2015-10-01 13:34:32 +0300
commit41b08e4a08b8caf445d2b7b59e2e76b73ab88a7b (patch)
tree88ea356912fba42d64efc8047c44369b4c84f8f3 /app/models
parentfc4f5eef99c53dee266cb416615fc17644a1c218 (diff)
parent8e05ee36f72813aa46d76594c17f3f8cdb0a12ed (diff)
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/project.rb40
-rw-r--r--app/models/namespace.rb4
-rw-r--r--app/models/project.rb6
-rw-r--r--app/models/project_services/gitlab_ci_service.rb6
4 files changed, 25 insertions, 31 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/namespace.rb b/app/models/namespace.rb
index 161a16ca61c..bc8525df5a5 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -137,7 +137,9 @@ class Namespace < ActiveRecord::Base
end
def send_update_instructions
- projects.each(&:send_move_instructions)
+ projects.each do |project|
+ project.send_move_instructions("#{path_was}/#{project.path}")
+ end
end
def kind
diff --git a/app/models/project.rb b/app/models/project.rb
index 4bcc16d8e9c..8527fa29808 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -481,8 +481,8 @@ class Project < ActiveRecord::Base
end
end
- def send_move_instructions
- NotificationService.new.project_was_moved(self)
+ def send_move_instructions(old_path_with_namespace)
+ NotificationService.new.project_was_moved(self, old_path_with_namespace)
end
def owner
@@ -624,7 +624,7 @@ class Project < ActiveRecord::Base
# So we basically we mute exceptions in next actions
begin
gitlab_shell.mv_repository("#{old_path_with_namespace}.wiki", "#{new_path_with_namespace}.wiki")
- send_move_instructions
+ send_move_instructions(old_path_with_namespace)
reset_events_cache
rescue
# Returning false does not rollback after_* transaction but gives
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)