From 0590aa9d6073e79ba47c4fe5c34318f6889c44d8 Mon Sep 17 00:00:00 2001 From: randx Date: Fri, 27 Jul 2012 11:22:05 +0300 Subject: commit.short_id as model method. Styled inline comment form --- app/models/commit.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 859bee29fa5..71c41350c95 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -114,6 +114,10 @@ class Commit @head = head end + def short_id(length = 10) + id.to_s[0..length] + end + def safe_message utf8 message end @@ -150,4 +154,8 @@ class Commit def prev_commit_id prev_commit.try :id end + + def parents_count + parents && parents.count || 0 + end end -- cgit v1.2.1