Commit ca7e4a948b7826bf17707996e30ad191ff3f2d58

Authored by Dmitriy Zaporozhets
1 parent 5ec09559

Use new tags/branches from gitlab_git

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/controllers/projects/tags_controller.rb
... ... @@ -8,7 +8,7 @@ class Projects::TagsController &lt; Projects::ApplicationController
8 8 before_filter :authorize_admin_project!, only: [:destroy]
9 9  
10 10 def index
11   - @tags = Kaminari.paginate_array(@repository.tags).page(params[:page]).per(30)
  11 + @tags = Kaminari.paginate_array(@repository.tags.reverse).page(params[:page]).per(30)
12 12 end
13 13  
14 14 def create
... ...
app/models/commit.rb
... ... @@ -16,29 +16,31 @@ class Commit
16 16 DIFF_HARD_LIMIT_FILES = 500
17 17 DIFF_HARD_LIMIT_LINES = 10000
18 18  
19   - def self.decorate(commits)
20   - commits.map { |c| self.new(c) }
21   - end
  19 + class << self
  20 + def decorate(commits)
  21 + commits.map { |c| self.new(c) }
  22 + end
22 23  
23   - # Calculate number of lines to render for diffs
24   - def self.diff_line_count(diffs)
25   - diffs.reduce(0){|sum, d| sum + d.diff.lines.count}
26   - end
  24 + # Calculate number of lines to render for diffs
  25 + def diff_line_count(diffs)
  26 + diffs.reduce(0){|sum, d| sum + d.diff.lines.count}
  27 + end
27 28  
28   - def self.diff_suppress?(diffs, line_count = nil)
29   - # optimize - check file count first
30   - return true if diffs.size > DIFF_SAFE_FILES
  29 + def diff_suppress?(diffs, line_count = nil)
  30 + # optimize - check file count first
  31 + return true if diffs.size > DIFF_SAFE_FILES
31 32  
32   - line_count ||= Commit::diff_line_count(diffs)
33   - line_count > DIFF_SAFE_LINES
34   - end
  33 + line_count ||= Commit::diff_line_count(diffs)
  34 + line_count > DIFF_SAFE_LINES
  35 + end
35 36  
36   - def self.diff_force_suppress?(diffs, line_count = nil)
37   - # optimize - check file count first
38   - return true if diffs.size > DIFF_HARD_LIMIT_FILES
  37 + def diff_force_suppress?(diffs, line_count = nil)
  38 + # optimize - check file count first
  39 + return true if diffs.size > DIFF_HARD_LIMIT_FILES
39 40  
40   - line_count ||= Commit::diff_line_count(diffs)
41   - line_count > DIFF_HARD_LIMIT_LINES
  41 + line_count ||= Commit::diff_line_count(diffs)
  42 + line_count > DIFF_HARD_LIMIT_LINES
  43 + end
42 44 end
43 45  
44 46 attr_accessor :raw
... ...
app/models/repository.rb
... ... @@ -57,7 +57,7 @@ class Repository
57 57  
58 58 def recent_branches(limit = 20)
59 59 branches.sort do |a, b|
60   - b.commit.committed_date <=> a.commit.committed_date
  60 + commit(b.target).committed_date <=> commit(a.target).committed_date
61 61 end[0..limit]
62 62 end
63 63  
... ...
app/views/projects/branches/_branch.html.haml
1   -- commit = Commit.new(Gitlab::Git::Commit.new(branch.commit))
  1 +- commit = @repository.commit(branch.target)
2 2 %li
3 3 %h4
4 4 = link_to project_commits_path(@project, branch.name) do
... ... @@ -19,10 +19,14 @@
19 19 = link_to project_branch_path(@project, branch.name), class: 'btn grouped btn-small remove-row', method: :delete, data: { confirm: 'Removed branch cannot be restored. Are you sure?'}, remote: true do
20 20 %i.icon-trash
21 21  
22   - %p
23   - = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do
24   - = commit.short_id
25   - = image_tag avatar_icon(commit.author_email), class: "avatar s16", alt: ''
26   - %span.light
27   - = gfm escape_once(truncate(commit.title, length: 40))
28   - #{time_ago_with_tooltip(commit.committed_date)}
  22 + - if commit
  23 + %p
  24 + = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do
  25 + = commit.short_id
  26 + = image_tag avatar_icon(commit.author_email), class: "avatar s16", alt: ''
  27 + %span.light
  28 + = gfm escape_once(truncate(commit.title, length: 40))
  29 + #{time_ago_with_tooltip(commit.committed_date)}
  30 + - else
  31 + %p
  32 + Cant find HEAD commit for this branch
... ...
app/views/projects/tags/_tag.html.haml 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +- commit = @repository.commit(tag.target)
  2 +%li
  3 + %h4
  4 + = link_to project_commits_path(@project, tag.name), class: "" do
  5 + %i.icon-tag
  6 + = tag.name
  7 + .pull-right
  8 + %small.cdark
  9 + %i.icon-calendar
  10 + #{time_ago_with_tooltip(commit.committed_date)}
  11 + %p.prepend-left-20
  12 + = link_to commit.short_id(8), project_commit_path(@project, commit), class: "monospace"
  13 + &ndash;
  14 + = link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "cdark"
  15 +
  16 + %span.pull-right
  17 + - if can? current_user, :download_code, @project
  18 + = render 'projects/repositories/download_archive', ref: tag.name, btn_class: 'grouped btn-group-small'
  19 + - if can?(current_user, :admin_project, @project)
  20 + = link_to project_tag_path(@project, tag.name), class: 'btn btn-small remove-row grouped', method: :delete, data: { confirm: 'Removed tag cannot be restored. Are you sure?'}, remote: true do
  21 + %i.icon-trash
  22 +
... ...
app/views/projects/tags/index.html.haml
... ... @@ -13,29 +13,7 @@
13 13 - unless @tags.empty?
14 14 %ul.bordered-list
15 15 - @tags.each do |tag|
16   - - commit = Commit.new(Gitlab::Git::Commit.new(tag.commit))
17   - %li
18   - %h4
19   - = link_to project_commits_path(@project, tag.name), class: "" do
20   - %i.icon-tag
21   - = tag.name
22   - %small
23   - = truncate(tag.message || '', length: 70)
24   - .pull-right
25   - %small.cdark
26   - %i.icon-calendar
27   - #{time_ago_with_tooltip(commit.committed_date)}
28   - %p.prepend-left-20
29   - = link_to commit.short_id(8), project_commit_path(@project, commit), class: "monospace"
30   - &ndash;
31   - = link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "cdark"
32   -
33   - %span.pull-right
34   - - if can? current_user, :download_code, @project
35   - = render 'projects/repositories/download_archive', ref: tag.name, btn_class: 'grouped btn-group-small'
36   - - if can?(current_user, :admin_project, @project)
37   - = link_to project_tag_path(@project, tag.name), class: 'btn btn-small remove-row grouped', method: :delete, data: { confirm: 'Removed tag cannot be restored. Are you sure?'}, remote: true do
38   - %i.icon-trash
  16 + = render 'tag', tag: tag
39 17  
40 18 = paginate @tags, theme: 'gitlab'
41 19  
... ...