diff options
author | Achilleas Pipinellis <axilleas@axilleas.me> | 2016-06-18 09:23:31 +0200 |
---|---|---|
committer | Achilleas Pipinellis <axilleas@axilleas.me> | 2016-06-18 09:23:31 +0200 |
commit | 56777e89562fe9c81f6e9237bff9cee6420fc093 (patch) | |
tree | a18d1dfad849311b38812db98d3f9cad520a49dc /app/models/deployment.rb | |
parent | 9169c7e81fb906cf9f419d195d73a585b19dafbc (diff) | |
parent | 00906b5bb6cde8cb60281109060a519a54000c61 (diff) | |
download | gitlab-ce-56777e89562fe9c81f6e9237bff9cee6420fc093.tar.gz |
Merge branch 'master' into ci-scala-example
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r-- | app/models/deployment.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb new file mode 100644 index 00000000000..e498ca96e3c --- /dev/null +++ b/app/models/deployment.rb @@ -0,0 +1,29 @@ +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 + + 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 +end |