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

46 lines
856 B
Ruby
Raw Normal View History

class Deployment < ActiveRecord::Base
include InternalId
belongs_to :project, required: true, validate: true
belongs_to :environment, required: true, validate: true
belongs_to :user
belongs_to :deployable, polymorphic: true
validates :sha, presence: true
validates :ref, presence: true
delegate :name, to: :environment, prefix: true
2016-08-24 12:49:21 +05:30
after_save :keep_around_commit
def commit
project.commit(sha)
end
def commit_title
commit.try(:title)
end
def short_sha
Commit.truncate_sha(sha)
end
def last?
self == environment.last_deployment
end
2016-08-24 12:49:21 +05:30
def keep_around_commit
project.repository.keep_around(self.sha)
end
def manual_actions
deployable.try(:other_actions)
end
2016-09-13 17:45:13 +05:30
def includes_commit?(commit)
return false unless commit
project.repository.is_ancestor?(commit.id, sha)
end
end