diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/ci/application_controller.rb | 8 | ||||
-rw-r--r-- | app/models/ci/build.rb | 3 | ||||
-rw-r--r-- | app/models/ci/commit.rb | 10 | ||||
-rw-r--r-- | app/models/ci/project.rb | 29 | ||||
-rw-r--r-- | app/models/project.rb | 1 |
5 files changed, 27 insertions, 24 deletions
diff --git a/app/controllers/ci/application_controller.rb b/app/controllers/ci/application_controller.rb index d8227e632e4..da77e2b94e8 100644 --- a/app/controllers/ci/application_controller.rb +++ b/app/controllers/ci/application_controller.rb @@ -11,10 +11,10 @@ module Ci private def check_enable_flag! - unless current_application_settings.ci_enabled - redirect_to(disabled_ci_projects_path) - return - end + # unless current_application_settings.ci_enabled + # redirect_to(disabled_ci_projects_path) + # return + # end end def authenticate_public_page! diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 16ff6e38630..9ac47ccfe4a 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -79,7 +79,6 @@ module Ci new_build.commands = build.commands new_build.tag_list = build.tag_list new_build.commit_id = build.commit_id - new_build.project_id = build.project_id new_build.name = build.name new_build.allow_failure = build.allow_failure new_build.stage = build.stage @@ -187,7 +186,7 @@ module Ci end def project_id - commit.project_id + commit.gl_project.gitlab_id end def project_name diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb index 31638c7e1dc..9a719787649 100644 --- a/app/models/ci/commit.rb +++ b/app/models/ci/commit.rb @@ -32,14 +32,15 @@ module Ci sha[0...8] end - def project - @project ||= gl_project.gitlab_ci_project - end - def to_param sha end + def project + @project ||= gl_project.gitlab_ci_project + @project ||= gl_project.create_gitlab_ci_project + end + def last_build builds.order(:id).last end @@ -115,7 +116,6 @@ module Ci builds_attrs = config_processor.builds_for_stage_and_ref(stage, ref, tag) builds_attrs.map do |build_attrs| builds.create!({ - project: project, name: build_attrs[:name], commands: build_attrs[:script], tag_list: build_attrs[:tags], diff --git a/app/models/ci/project.rb b/app/models/ci/project.rb index ea7547f5d43..89bbbea5c5a 100644 --- a/app/models/ci/project.rb +++ b/app/models/ci/project.rb @@ -33,15 +33,12 @@ module Ci belongs_to :gl_project, class_name: '::Project', foreign_key: :gitlab_id - has_many :commits, through: :gl_project, class_name: 'Ci::Commit', foreign_key: :gl_project_id - has_many :builds, through: :commits, dependent: :destroy, class_name: 'Ci::Build' has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject' has_many :runners, through: :runner_projects, class_name: 'Ci::Runner' has_many :web_hooks, dependent: :destroy, class_name: 'Ci::WebHook' has_many :events, dependent: :destroy, class_name: 'Ci::Event' has_many :variables, dependent: :destroy, class_name: 'Ci::Variable' has_many :triggers, dependent: :destroy, class_name: 'Ci::Trigger' - has_one :last_commit, through: :gl_project, class_name: 'Ci::Commit' # Project services has_many :services, dependent: :destroy, class_name: 'Ci::Service' @@ -51,17 +48,19 @@ module Ci accepts_nested_attributes_for :variables, allow_destroy: true + delegate :commits, :builds, :last_commit, to: :gl_project + # # Validations # validates_presence_of :name, :timeout, :token, :default_ref, - :path, :ssh_url_to_repo, :gitlab_id + :path, :ssh_url_to_repo, :gitlab_id validates_uniqueness_of :gitlab_id validates :polling_interval, - presence: true, - if: ->(project) { project.always_build.present? } + presence: true, + if: ->(project) { project.always_build.present? } scope :public_only, ->() { where(public: true) } @@ -79,12 +78,12 @@ 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, + 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, email_only_broken_builds: current_application_settings.all_broken_builds, } @@ -125,10 +124,14 @@ 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 - @tracked_refs ||= default_ref.split(",").map{|ref| ref.strip} + @tracked_refs ||= default_ref.split(",").map { |ref| ref.strip } end def valid_token? token diff --git a/app/models/project.rb b/app/models/project.rb index efa573c82b9..9ecf16d9812 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -119,6 +119,7 @@ class Project < ActiveRecord::Base has_many :users_star_projects, dependent: :destroy has_many :starrers, through: :users_star_projects, source: :user has_many :commits, ->() { order('CASE WHEN ci_commits.committed_at IS NULL THEN 0 ELSE 1 END', :committed_at, :id) }, dependent: :destroy, class_name: 'Ci::Commit', foreign_key: :gl_project_id + has_many :builds, through: :commits, dependent: :destroy, class_name: 'Ci::Build' has_one :last_commit, -> { order 'ci_commits.created_at DESC' }, class_name: 'Ci::Commit', foreign_key: :gl_project_id has_one :import_data, dependent: :destroy, class_name: "ProjectImportData" |