diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-10 16:30:14 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-10 16:30:14 +0300 |
commit | ea04ed7879ad7177bef7a6dbe3bf90d76ebb8b45 (patch) | |
tree | 349f1cae12c591208780b44d0e04c53679f72ad5 | |
parent | daa55f31d899819069ddbaa9596769a233b5a729 (diff) | |
download | gitlab-ce-ea04ed7879ad7177bef7a6dbe3bf90d76ebb8b45.tar.gz |
Use 8chars short sha for commit in views
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/models/commit.rb | 8 | ||||
-rw-r--r-- | app/views/projects/blame/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/commits/_commit.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/commits/_inline_commit.html.haml | 2 | ||||
-rw-r--r-- | spec/models/commit_spec.rb | 2 |
5 files changed, 11 insertions, 5 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index c30a630429a..cbe0a39bc70 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -27,8 +27,9 @@ class Commit diffs.reduce(0) { |sum, d| sum + d.diff.lines.count } end + # Truncate sha to 8 characters def truncate_sha(sha) - sha[0..10] + sha[0..7] end end @@ -128,6 +129,11 @@ class Commit super end + # Truncate sha to 8 characters + def short_id + @raw.short_id(7) + end + def parents @parents ||= Commit.decorate(super) end diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml index e5cde488c3c..bdf02c6285d 100644 --- a/app/views/projects/blame/show.html.haml +++ b/app/views/projects/blame/show.html.haml @@ -15,7 +15,7 @@ %tr %td.blame-commit %span.commit - = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" + = link_to commit.short_id, project_commit_path(@project, commit), class: "commit_short_id" = commit_author_link(commit, avatar: true, size: 16) diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index 68852ba973f..1eb17f760dc 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -1,6 +1,6 @@ %li.commit.js-toggle-container .commit-row-title - = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id" + = link_to commit.short_id, project_commit_path(project, commit), class: "commit_short_id" %span.str-truncated = link_to_gfm commit.title, project_commit_path(project, commit.id), class: "commit-row-message" diff --git a/app/views/projects/commits/_inline_commit.html.haml b/app/views/projects/commits/_inline_commit.html.haml index b36369b4285..574599aa2d2 100644 --- a/app/views/projects/commits/_inline_commit.html.haml +++ b/app/views/projects/commits/_inline_commit.html.haml @@ -1,6 +1,6 @@ %li.commit.inline-commit .commit-row-title - = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id" + = link_to commit.short_id, project_commit_path(project, commit), class: "commit_short_id" %span.str-truncated = link_to_gfm commit.title, project_commit_path(project, commit.id), class: "commit-row-message" diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 24bbf4f57da..a6ec44da4be 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -75,7 +75,7 @@ eos it_behaves_like 'a mentionable' do let(:subject) { commit } let(:mauthor) { create :user, email: commit.author_email } - let(:backref_text) { "commit #{subject.short_id}" } + let(:backref_text) { "commit #{subject.id}" } let(:set_mentionable_text) { ->(txt){ subject.stub(safe_message: txt) } } # Include the subject in the repository stub. |