diff options
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 33087b3..3532035 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -22,6 +22,10 @@ class Commit < ActiveRecord::Base validates_presence_of :ref, :sha, :before_sha, :push_data validate :valid_commit_sha + def self.truncate_sha(sha) + sha[0...8] + end + def to_param sha end @@ -31,13 +35,17 @@ class Commit < ActiveRecord::Base end def valid_commit_sha - if self.sha =~ /\A00000000/ + if self.sha == Git::BLANK_SHA self.errors.add(:sha, " cant be 00000000 (branch removal)") end end + def new_branch? + before_sha == Git::BLANK_SHA + end + def compare? - gitlab? && before_sha + gitlab? && !new_branch? end def gitlab? @@ -61,11 +69,11 @@ class Commit < ActiveRecord::Base end def short_before_sha - before_sha[0..8] + Commit.truncate_sha(before_sha) end def short_sha - sha[0..8] + Commit.truncate_sha(sha) end def commit_data |