Commit ca7e4a94 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Use new tags/branches from gitlab_git

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 5ec09559
...@@ -8,7 +8,7 @@ class Projects::TagsController < Projects::ApplicationController ...@@ -8,7 +8,7 @@ class Projects::TagsController < Projects::ApplicationController
before_filter :authorize_admin_project!, only: [:destroy] before_filter :authorize_admin_project!, only: [:destroy]
def index def index
@tags = Kaminari.paginate_array(@repository.tags).page(params[:page]).per(30) @tags = Kaminari.paginate_array(@repository.tags.reverse).page(params[:page]).per(30)
end end
def create def create
......
...@@ -16,16 +16,17 @@ class Commit ...@@ -16,16 +16,17 @@ class Commit
DIFF_HARD_LIMIT_FILES = 500 DIFF_HARD_LIMIT_FILES = 500
DIFF_HARD_LIMIT_LINES = 10000 DIFF_HARD_LIMIT_LINES = 10000
def self.decorate(commits) class << self
def decorate(commits)
commits.map { |c| self.new(c) } commits.map { |c| self.new(c) }
end end
# Calculate number of lines to render for diffs # Calculate number of lines to render for diffs
def self.diff_line_count(diffs) def diff_line_count(diffs)
diffs.reduce(0){|sum, d| sum + d.diff.lines.count} diffs.reduce(0){|sum, d| sum + d.diff.lines.count}
end end
def self.diff_suppress?(diffs, line_count = nil) def diff_suppress?(diffs, line_count = nil)
# optimize - check file count first # optimize - check file count first
return true if diffs.size > DIFF_SAFE_FILES return true if diffs.size > DIFF_SAFE_FILES
...@@ -33,13 +34,14 @@ class Commit ...@@ -33,13 +34,14 @@ class Commit
line_count > DIFF_SAFE_LINES line_count > DIFF_SAFE_LINES
end end
def self.diff_force_suppress?(diffs, line_count = nil) def diff_force_suppress?(diffs, line_count = nil)
# optimize - check file count first # optimize - check file count first
return true if diffs.size > DIFF_HARD_LIMIT_FILES return true if diffs.size > DIFF_HARD_LIMIT_FILES
line_count ||= Commit::diff_line_count(diffs) line_count ||= Commit::diff_line_count(diffs)
line_count > DIFF_HARD_LIMIT_LINES line_count > DIFF_HARD_LIMIT_LINES
end end
end
attr_accessor :raw attr_accessor :raw
......
...@@ -57,7 +57,7 @@ class Repository ...@@ -57,7 +57,7 @@ class Repository
def recent_branches(limit = 20) def recent_branches(limit = 20)
branches.sort do |a, b| branches.sort do |a, b|
b.commit.committed_date <=> a.commit.committed_date commit(b.target).committed_date <=> commit(a.target).committed_date
end[0..limit] end[0..limit]
end end
......
- commit = Commit.new(Gitlab::Git::Commit.new(branch.commit)) - commit = @repository.commit(branch.target)
%li %li
%h4 %h4
= link_to project_commits_path(@project, branch.name) do = link_to project_commits_path(@project, branch.name) do
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
= 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 = 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
%i.icon-trash %i.icon-trash
- if commit
%p %p
= link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do
= commit.short_id = commit.short_id
...@@ -26,3 +27,6 @@ ...@@ -26,3 +27,6 @@
%span.light %span.light
= gfm escape_once(truncate(commit.title, length: 40)) = gfm escape_once(truncate(commit.title, length: 40))
#{time_ago_with_tooltip(commit.committed_date)} #{time_ago_with_tooltip(commit.committed_date)}
- else
%p
Cant find HEAD commit for this branch
- commit = @repository.commit(tag.target)
%li
%h4
= link_to project_commits_path(@project, tag.name), class: "" do
%i.icon-tag
= tag.name
.pull-right
%small.cdark
%i.icon-calendar
#{time_ago_with_tooltip(commit.committed_date)}
%p.prepend-left-20
= link_to commit.short_id(8), project_commit_path(@project, commit), class: "monospace"
&ndash;
= link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "cdark"
%span.pull-right
- if can? current_user, :download_code, @project
= render 'projects/repositories/download_archive', ref: tag.name, btn_class: 'grouped btn-group-small'
- if can?(current_user, :admin_project, @project)
= 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
%i.icon-trash
...@@ -13,29 +13,7 @@ ...@@ -13,29 +13,7 @@
- unless @tags.empty? - unless @tags.empty?
%ul.bordered-list %ul.bordered-list
- @tags.each do |tag| - @tags.each do |tag|
- commit = Commit.new(Gitlab::Git::Commit.new(tag.commit)) = render 'tag', tag: tag
%li
%h4
= link_to project_commits_path(@project, tag.name), class: "" do
%i.icon-tag
= tag.name
%small
= truncate(tag.message || '', length: 70)
.pull-right
%small.cdark
%i.icon-calendar
#{time_ago_with_tooltip(commit.committed_date)}
%p.prepend-left-20
= link_to commit.short_id(8), project_commit_path(@project, commit), class: "monospace"
&ndash;
= link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "cdark"
%span.pull-right
- if can? current_user, :download_code, @project
= render 'projects/repositories/download_archive', ref: tag.name, btn_class: 'grouped btn-group-small'
- if can?(current_user, :admin_project, @project)
= 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
%i.icon-trash
= paginate @tags, theme: 'gitlab' = paginate @tags, theme: 'gitlab'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment