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:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-10-05 11:14:33 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2015-10-05 11:15:40 +0300
commite3d870d7fc282a1f0a1028996c8b44e5d32b9cbf (patch)
tree578278b2435415d6684073bafea9d08d24fcf17f /app
parent546a3c6561fbe967cc37ccc3229b71893cd20c34 (diff)
Add user to Ci::Build to have pusher email address
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/build.rb6
-rw-r--r--app/models/ci/commit.rb4
-rw-r--r--app/models/project_services/gitlab_ci_service.rb2
-rw-r--r--app/models/user.rb1
-rw-r--r--app/services/ci/create_builds_service.rb4
-rw-r--r--app/services/ci/create_commit_service.rb16
6 files changed, 11 insertions, 22 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index bf3e8915205..bfdc1c7486e 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -32,9 +32,9 @@ module Ci
belongs_to :commit, class_name: 'Ci::Commit'
belongs_to :runner, class_name: 'Ci::Runner'
belongs_to :trigger_request, class_name: 'Ci::TriggerRequest'
+ belongs_to :user
serialize :options
- serialize :push_data
validates :commit, presence: true
validates :status, presence: true
@@ -196,8 +196,8 @@ module Ci
def project_recipients
recipients = project.email_recipients.split(' ')
- if project.email_add_pusher? && push_data[:user_email].present?
- recipients << push_data[:user_email]
+ if project.email_add_pusher? && user.present? && user.notification_email.present?
+ recipients << user.notification_email
end
recipients.uniq
diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb
index 35134b6628e..3c577e3f081 100644
--- a/app/models/ci/commit.rb
+++ b/app/models/ci/commit.rb
@@ -96,10 +96,10 @@ module Ci
builds_without_retry.group(:stage_idx).select(:stage).last
end
- def create_builds(ref, tag, push_data, trigger_request = nil)
+ def create_builds(ref, tag, user, trigger_request = nil)
return if skip_ci? && trigger_request.blank?
return unless config_processor
- CreateBuildsService.new.execute(self, config_processor, ref, tag, push_data, trigger_request)
+ CreateBuildsService.new.execute(self, config_processor, ref, tag, user, trigger_request)
end
def refs
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index fd108516530..8e2b395494e 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -52,7 +52,7 @@ class GitlabCiService < CiService
ci_project = Ci::Project.find_by(gitlab_id: project.id)
if ci_project
- Ci::CreateCommitService.new.execute(ci_project, data)
+ Ci::CreateCommitService.new.execute(ci_project, data, current_user)
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 1069f8e3664..c7e3992b6a1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -130,6 +130,7 @@ class User < ActiveRecord::Base
has_many :assigned_merge_requests, dependent: :destroy, foreign_key: :assignee_id, class_name: "MergeRequest"
has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: :destroy
has_one :abuse_report, dependent: :destroy
+ has_many :ci_builds, dependent: :nullify, class_name: 'Ci::Build'
#
diff --git a/app/services/ci/create_builds_service.rb b/app/services/ci/create_builds_service.rb
index e9c85410e5c..77a4305071c 100644
--- a/app/services/ci/create_builds_service.rb
+++ b/app/services/ci/create_builds_service.rb
@@ -1,6 +1,6 @@
module Ci
class CreateBuildsService
- def execute(commit, ref, tag, push_data, config_processor, trigger_request)
+ def execute(commit, ref, tag, user, config_processor, trigger_request)
config_processor.stages.any? do |stage|
builds_attrs = config_processor.builds_for_stage_and_ref(stage, ref, tag)
builds_attrs.map do |build_attrs|
@@ -17,7 +17,7 @@ module Ci
trigger_request: trigger_request,
ref: ref,
tag: tag,
- push_data: push_data,
+ user: user,
})
end
end
diff --git a/app/services/ci/create_commit_service.rb b/app/services/ci/create_commit_service.rb
index 9120a82edcd..edbb07580c9 100644
--- a/app/services/ci/create_commit_service.rb
+++ b/app/services/ci/create_commit_service.rb
@@ -1,6 +1,6 @@
module Ci
class CreateCommitService
- def execute(project, params)
+ def execute(project, params, user)
before_sha = params[:before]
sha = params[:checkout_sha] || params[:after]
origin_ref = params[:ref]
@@ -17,21 +17,9 @@ module Ci
end
tag = origin_ref.start_with?('refs/tags/')
- push_data = {
- before: before_sha,
- after: sha,
- ref: ref,
- user_name: params[:user_name],
- user_email: params[:user_email],
- repository: params[:repository],
- commits: params[:commits],
- total_commits_count: params[:total_commits_count],
- ci_yaml_file: params[:ci_yaml_file]
- }
-
commit = project.gl_project.ensure_ci_commit(sha)
commit.update_committed!
- commit.create_builds(ref, tag, push_data)
+ commit.create_builds(ref, tag, user)
commit
end