debian-mirror-gitlab/app/models/generic_commit_status.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
743 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2015-10-24 18:46:33 +05:30
class GenericCommitStatus < CommitStatus
2020-02-01 01:16:34 +05:30
EXTERNAL_STAGE_IDX = 1_000_000
2019-07-31 22:56:46 +05:30
validates :target_url, addressable_url: true,
2017-08-17 22:00:37 +05:30
length: { maximum: 255 },
allow_nil: true
2020-02-01 01:16:34 +05:30
validate :name_uniqueness_across_types, unless: :importing?
2017-08-17 22:00:37 +05:30
2015-10-24 18:46:33 +05:30
# GitHub compatible API
alias_attribute :context, :name
def tags
[:external]
end
2017-08-17 22:00:37 +05:30
def detailed_status(current_user)
Gitlab::Ci::Status::External::Factory
.new(self, current_user)
.fabricate!
end
2020-02-01 01:16:34 +05:30
private
def name_uniqueness_across_types
return if !pipeline || name.blank?
if pipeline.statuses.by_name(name).where.not(type: type).exists?
errors.add(:name, :taken)
end
end
2015-10-24 18:46:33 +05:30
end