diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-07-15 15:42:29 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-07-15 17:42:27 +0200 |
commit | 1556d4848d4753b7bddd8430cf223b91e6f47b0f (patch) | |
tree | bb4c140f0d7c6fb4509c3830bf7de7d586e3363b /app/models | |
parent | 8b7932c21951de172d531ab8a3e9506c98db7483 (diff) | |
download | gitlab-ce-1556d4848d4753b7bddd8430cf223b91e6f47b0f.tar.gz |
Track a user who created a pipeline
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/pipeline.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 1 |
3 files changed, 5 insertions, 2 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index fa4071e2482..cb284ba1e1c 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -6,6 +6,8 @@ module Ci self.table_name = 'ci_commits' belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id + belongs_to :user + has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id has_many :builds, class_name: 'Ci::Build', foreign_key: :commit_id has_many :trigger_requests, dependent: :destroy, class_name: 'Ci::TriggerRequest', foreign_key: :commit_id diff --git a/app/models/project.rb b/app/models/project.rb index e7b9835692d..dba3b3413ef 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1038,8 +1038,8 @@ class Project < ActiveRecord::Base pipelines.order(id: :desc).find_by(sha: sha, ref: ref) end - def ensure_pipeline(sha, ref) - pipeline(sha, ref) || pipelines.create(sha: sha, ref: ref) + def ensure_pipeline(sha, ref, current_user = nil) + pipeline(sha, ref) || pipelines.create(sha: sha, ref: ref, user: current_user) end def enable_ci diff --git a/app/models/user.rb b/app/models/user.rb index 7a72c202150..3d0a033785c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -85,6 +85,7 @@ class User < ActiveRecord::Base has_one :abuse_report, dependent: :destroy has_many :spam_logs, dependent: :destroy has_many :builds, dependent: :nullify, class_name: 'Ci::Build' + has_many :pipelines, dependent: :nullify, class_name: 'Ci::Pipeline' has_many :todos, dependent: :destroy has_many :notification_settings, dependent: :destroy has_many :award_emoji, dependent: :destroy |