summaryrefslogtreecommitdiff
path: root/app/models/commit_status.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/commit_status.rb')
-rw-r--r--app/models/commit_status.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 39a6247b3b2..8d38835fb3b 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -17,7 +17,7 @@ class CommitStatus < ApplicationRecord
belongs_to :auto_canceled_by, class_name: 'Ci::Pipeline'
delegate :commit, to: :pipeline
- delegate :sha, :short_sha, to: :pipeline
+ delegate :sha, :short_sha, :before_sha, to: :pipeline
validates :pipeline, presence: true, unless: :importing?
validates :name, presence: true, unless: :importing?
@@ -47,6 +47,12 @@ class CommitStatus < ApplicationRecord
scope :after_stage, -> (index) { where('stage_idx > ?', index) }
scope :processables, -> { where(type: %w[Ci::Build Ci::Bridge]) }
scope :for_ids, -> (ids) { where(id: ids) }
+ scope :for_ref, -> (ref) { where(ref: ref) }
+ scope :by_name, -> (name) { where(name: name) }
+
+ scope :for_project_paths, -> (paths) do
+ where(project: Project.where_full_path_in(Array(paths)))
+ end
scope :with_preloads, -> do
preload(:project, :user)
@@ -176,10 +182,6 @@ class CommitStatus < ApplicationRecord
will_save_change_to_status?
end
- def before_sha
- pipeline.before_sha || Gitlab::Git::BLANK_SHA
- end
-
def group_name
name.to_s.gsub(%r{\d+[\s:/\\]+\d+\s*}, '').strip
end