deployment.rb 560 字节
Newer Older
1 2 3
class Deployment < ActiveRecord::Base
  include InternalId

4 5
  belongs_to :project, required: true, validate: true
  belongs_to :environment, required: true, validate: true
6 7 8
  belongs_to :user
  belongs_to :deployable, polymorphic: true

K
Kamil Trzcinski 已提交
9 10
  validates :sha, presence: true
  validates :ref, presence: true
11 12 13 14 15 16 17 18 19 20 21 22

  delegate :name, to: :environment, prefix: true

  def commit
    project.commit(sha)
  end

  def commit_title
    commit.try(:title)
  end

  def short_sha
K
Kamil Trzcinski 已提交
23
    Commit.truncate_sha(sha)
24
  end
25 26 27 28

  def last?
    self == environment.last_deployment
  end
29
end