Merge branch 'refactor/gitlab_git'

This commit is contained in:
Dmitriy Zaporozhets 2013-04-01 20:53:00 +03:00
commit 76a4cbe464
71 changed files with 827 additions and 745 deletions

View file

@ -12,7 +12,6 @@ class CommitLoadContext < BaseContext
commit = project.repository.commit(params[:id])
if commit
commit = CommitDecorator.decorate(commit)
line_notes = project.notes.for_commit_id(commit.id).inline
result[:commit] = commit

View file

@ -8,7 +8,6 @@ class BlameController < ProjectResourceController
before_filter :require_non_empty_project
def show
@repo = @project.repo
@blame = Grit::Blob.blame(@repo, @commit.id, @path)
@blame = Gitlab::Git::Blame.new(project.repository, @commit.id, @path)
end
end

View file

@ -13,7 +13,6 @@ class CommitsController < ProjectResourceController
@limit, @offset = (params[:limit] || 40), (params[:offset] || 0)
@commits = @repo.commits(@ref, @path, @limit, @offset)
@commits = CommitDecorator.decorate_collection(@commits)
respond_to do |format|
format.html # index.html.erb

View file

@ -8,15 +8,13 @@ class CompareController < ProjectResourceController
end
def show
result = Commit.compare(project, params[:from], params[:to])
compare = Gitlab::Git::Compare.new(project.repository, params[:from], params[:to])
@commits = result[:commits]
@commit = result[:commit]
@diffs = result[:diffs]
@refs_are_same = result[:same]
@commits = compare.commits
@commit = compare.commit
@diffs = compare.diffs
@refs_are_same = compare.same
@line_notes = []
@commits = CommitDecorator.decorate_collection(@commits)
end
def create

View file

@ -94,12 +94,10 @@ class MergeRequestsController < ProjectResourceController
def branch_from
@commit = @repository.commit(params[:ref])
@commit = CommitDecorator.decorate(@commit)
end
def branch_to
@commit = @repository.commit(params[:ref])
@commit = CommitDecorator.decorate(@commit)
end
def ci_status
@ -143,7 +141,6 @@ class MergeRequestsController < ProjectResourceController
# Get commits from repository
# or from cache if already merged
@commits = @merge_request.commits
@commits = CommitDecorator.decorate_collection(@commits)
@allowed_to_merge = allowed_to_merge?
@show_merge_controls = @merge_request.opened? && @commits.any? && @allowed_to_merge

View file

@ -34,7 +34,6 @@ class RefsController < ProjectResourceController
@logs = contents.map do |content|
file = params[:path] ? File.join(params[:path], content.name) : content.name
last_commit = @repo.commits(@commit.id, file, 1).last
last_commit = CommitDecorator.decorate(last_commit)
{
file_name: content.name,
commit: last_commit
@ -49,9 +48,7 @@ class RefsController < ProjectResourceController
@repo = project.repository
@commit = @repo.commit(@ref)
@commit = CommitDecorator.decorate(@commit)
@tree = Tree.new(@commit.tree, @ref, params[:path])
@tree = TreeDecorator.new(@tree)
@hex_path = Digest::SHA1.hexdigest(params[:path] || "")
if params[:path]

View file

@ -1,93 +0,0 @@
class CommitDecorator < ApplicationDecorator
decorates :commit
# Returns a string describing the commit for use in a link title
#
# Example
#
# "Commit: Alex Denisov - Project git clone panel"
def link_title
"Commit: #{author_name} - #{title}"
end
# Returns the commits title.
#
# Usually, the commit title is the first line of the commit message.
# In case this first line is longer than 80 characters, it is cut off
# after 70 characters and ellipses (`&hellp;`) are appended.
def title
title = safe_message
return no_commit_message if title.blank?
title_end = title.index(/\n/)
if (!title_end && title.length > 80) || (title_end && title_end > 80)
title[0..69] << "&hellip;".html_safe
else
title.split(/\n/, 2).first
end
end
# Returns the commits description
#
# cut off, ellipses (`&hellp;`) are prepended to the commit message.
def description
description = safe_message
title_end = description.index(/\n/)
if (!title_end && description.length > 80) || (title_end && title_end > 80)
"&hellip;".html_safe << description[70..-1]
else
description.split(/\n/, 2)[1].try(:chomp)
end
end
# Returns a link to the commit author. If the author has a matching user and
# is a member of the current @project it will link to the team member page.
# Otherwise it will link to the author email as specified in the commit.
#
# options:
# avatar: true will prepend the avatar image
# size: size of the avatar image in px
def author_link(options = {})
person_link(options.merge source: :author)
end
# Just like #author_link but for the committer.
def committer_link(options = {})
person_link(options.merge source: :committer)
end
protected
def no_commit_message
"--no commit message"
end
# Private: Returns a link to a person. If the person has a matching user and
# is a member of the current @project it will link to the team member page.
# Otherwise it will link to the person email as specified in the commit.
#
# options:
# source: one of :author or :committer
# avatar: true will prepend the avatar image
# size: size of the avatar image in px
def person_link(options = {})
source_name = send "#{options[:source]}_name".to_sym
source_email = send "#{options[:source]}_email".to_sym
text = if options[:avatar]
avatar = h.image_tag h.gravatar_icon(source_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]}", width: options[:size], alt: ""
%Q{#{avatar} <span class="commit-#{options[:source]}-name">#{source_name}</span>}
else
source_name
end
user = User.where('name like ? or email like ?', source_name, source_email).first
if user.nil?
h.mail_to(source_email, text.html_safe, class: "commit-#{options[:source]}-link")
else
h.link_to(text.html_safe, h.user_path(user), class: "commit-#{options[:source]}-link")
end
end
end

View file

@ -1,33 +0,0 @@
class TreeDecorator < ApplicationDecorator
decorates :tree
def breadcrumbs(max_links = 2)
if path
part_path = ""
parts = path.split("\/")
yield('..', nil) if parts.count > max_links
parts.each do |part|
part_path = File.join(part_path, part) unless part_path.empty?
part_path = part if part_path.empty?
next unless parts.last(2).include?(part) if parts.count > max_links
yield(part, h.tree_join(ref, part_path))
end
end
end
def up_dir?
path.present?
end
def up_dir_path
file = File.join(path, "..")
h.tree_join(ref, file)
end
def readme
@readme ||= contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }
end
end

View file

@ -96,7 +96,7 @@ module ApplicationHelper
]
project_nav = []
if @project && @project.repository && @project.repository.root_ref
if @project && @project.repository.exists? && @project.repository.root_ref
project_nav = [
{ label: "#{simple_sanitize(@project.name_with_namespace)} - Issues", url: project_issues_path(@project) },
{ label: "#{simple_sanitize(@project.name_with_namespace)} - Commits", url: project_commits_path(@project, @ref || @project.repository.root_ref) },

View file

@ -1,4 +1,20 @@
module CommitsHelper
# Returns a link to the commit author. If the author has a matching user and
# is a member of the current @project it will link to the team member page.
# Otherwise it will link to the author email as specified in the commit.
#
# options:
# avatar: true will prepend the avatar image
# size: size of the avatar image in px
def commit_author_link(commit, options = {})
commit_person_link(commit, options.merge(source: :author))
end
# Just like #author_link but for the committer.
def commit_committer_link(commit, options = {})
commit_person_link(commit, options.merge(source: :committer))
end
def identification_type(line)
if line[0] == "+"
"new"
@ -93,9 +109,7 @@ module CommitsHelper
end
def commit_to_html commit
if commit.model
escape_javascript(render 'commits/commit', commit: commit)
end
escape_javascript(render 'commits/commit', commit: commit)
end
def diff_line_content(line)
@ -105,4 +119,58 @@ module CommitsHelper
line
end
end
# Breadcrumb links for a Project and, if applicable, a tree path
def commits_breadcrumbs
return unless @project && @ref
# Add the root project link and the arrow icon
crumbs = content_tag(:li) do
content_tag(:span, nil, class: 'arrow') +
link_to(@project.name, project_commits_path(@project, @ref))
end
if @path
parts = @path.split('/')
parts.each_with_index do |part, i|
crumbs += content_tag(:span, '/', class: 'divider')
crumbs += content_tag(:li) do
# The text is just the individual part, but the link needs all the parts before it
link_to part, project_commits_path(@project, tree_join(@ref, parts[0..i].join('/')))
end
end
end
crumbs.html_safe
end
protected
# Private: Returns a link to a person. If the person has a matching user and
# is a member of the current @project it will link to the team member page.
# Otherwise it will link to the person email as specified in the commit.
#
# options:
# source: one of :author or :committer
# avatar: true will prepend the avatar image
# size: size of the avatar image in px
def commit_person_link(commit, options = {})
source_name = commit.send "#{options[:source]}_name".to_sym
source_email = commit.send "#{options[:source]}_email".to_sym
text = if options[:avatar]
avatar = image_tag(gravatar_icon(source_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]}", width: options[:size], alt: "")
%Q{#{avatar} <span class="commit-#{options[:source]}-name">#{source_name}</span>}
else
source_name
end
user = User.where('name like ? or email like ?', source_name, source_email).first
if user.nil?
mail_to(source_email, text.html_safe, class: "commit-#{options[:source]}-link")
else
link_to(text.html_safe, user_path(user), class: "commit-#{options[:source]}-link")
end
end
end

View file

@ -70,28 +70,26 @@ module TreeHelper
end
end
# Breadcrumb links for a Project and, if applicable, a tree path
def breadcrumbs
return unless @project && @ref
def tree_breadcrumbs(tree, max_links = 2)
if tree.path
part_path = ""
parts = tree.path.split("\/")
# Add the root project link and the arrow icon
crumbs = content_tag(:li) do
content_tag(:span, nil, class: 'arrow') +
link_to(@project.name, project_commits_path(@project, @ref))
end
yield('..', nil) if parts.count > max_links
if @path
parts = @path.split('/')
parts.each do |part|
part_path = File.join(part_path, part) unless part_path.empty?
part_path = part if part_path.empty?
parts.each_with_index do |part, i|
crumbs += content_tag(:span, '/', class: 'divider')
crumbs += content_tag(:li) do
# The text is just the individual part, but the link needs all the parts before it
link_to part, project_commits_path(@project, tree_join(@ref, parts[0..i].join('/')))
end
next unless parts.last(2).include?(part) if parts.count > max_links
yield(part, tree_join(tree.ref, part_path))
end
end
crumbs.html_safe
end
def up_dir_path tree
file = File.join(tree.path, "..")
tree_join(tree.ref, file)
end
end

View file

@ -3,7 +3,6 @@ module Emails
def note_commit_email(recipient_id, note_id)
@note = Note.find(note_id)
@commit = @note.noteable
@commit = CommitDecorator.decorate(@commit)
@project = @note.project
mail(to: recipient(recipient_id), subject: subject("note for commit #{@commit.short_id}", @commit.title))
end

View file

@ -8,174 +8,70 @@ class Commit
#
DIFF_SAFE_SIZE = 100
attr_accessor :commit, :head, :refs
delegate :message, :authored_date, :committed_date, :parents, :sha,
:date, :committer, :author, :diffs, :tree, :id, :stats,
:to_patch, to: :commit
class << self
def find_or_first(repo, commit_id = nil, root_ref)
commit = if commit_id
repo.commit(commit_id)
else
repo.commits(root_ref).first
end
Commit.new(commit) if commit
end
def fresh_commits(repo, n = 10)
commits = repo.heads.map do |h|
repo.commits(h.name, n).map { |c| Commit.new(c, h) }
end.flatten.uniq { |c| c.id }
commits.sort! do |x, y|
y.committed_date <=> x.committed_date
end
commits[0...n]
end
def commits_with_refs(repo, n = 20)
commits = repo.branches.map { |ref| Commit.new(ref.commit, ref) }
commits.sort! do |x, y|
y.committed_date <=> x.committed_date
end
commits[0..n]
end
def commits_since(repo, date)
commits = repo.heads.map do |h|
repo.log(h.name, nil, since: date).each { |c| Commit.new(c, h) }
end.flatten.uniq { |c| c.id }
commits.sort! do |x, y|
y.committed_date <=> x.committed_date
end
commits
end
def commits(repo, ref, path = nil, limit = nil, offset = nil)
if path
repo.log(ref, path, max_count: limit, skip: offset)
elsif limit && offset
repo.commits(ref, limit, offset)
else
repo.commits(ref)
end.map{ |c| Commit.new(c) }
end
def commits_between(repo, from, to)
repo.commits_between(from, to).map { |c| Commit.new(c) }
end
def compare(project, from, to)
result = {
commits: [],
diffs: [],
commit: nil,
same: false
}
return result unless from && to
first = project.repository.commit(to.try(:strip))
last = project.repository.commit(from.try(:strip))
if first && last
result[:same] = (first.id == last.id)
result[:commits] = project.repo.commits_between(last.id, first.id).map {|c| Commit.new(c)}
# Dont load diff for 100+ commits
result[:diffs] = if result[:commits].size > 100
[]
else
project.repo.diff(last.id, first.id) rescue []
end
result[:commit] = Commit.new(first)
end
result
end
def self.decorate(commits)
commits.map { |c| self.new(c) }
end
def initialize(raw_commit, head = nil)
attr_accessor :raw
def initialize(raw_commit)
raise "Nil as raw commit passed" unless raw_commit
@commit = raw_commit
@head = head
@raw = raw_commit
end
def short_id(length = 10)
id.to_s[0..length]
def id
@raw.id
end
def safe_message
@safe_message ||= message
end
def created_at
committed_date
end
def author_email
author.email
end
def author_name
author.name
end
# Was this commit committed by a different person than the original author?
def different_committer?
author_name != committer_name || author_email != committer_email
end
def committer_name
committer.name
end
def committer_email
committer.email
end
def prev_commit
@prev_commit ||= if parents.present?
Commit.new(parents.first)
else
nil
end
end
def prev_commit_id
prev_commit.try :id
end
# Shows the diff between the commit's parent and the commit.
# Returns a string describing the commit for use in a link title
#
# Cuts out the header and stats from #to_patch and returns only the diff.
def to_diff
# see Grit::Commit#show
patch = to_patch
# discard lines before the diff
lines = patch.split("\n")
while !lines.first.start_with?("diff --git") do
lines.shift
end
lines.pop if lines.last =~ /^[\d.]+$/ # Git version
lines.pop if lines.last == "-- " # end of diff
lines.join("\n")
# Example
#
# "Commit: Alex Denisov - Project git clone panel"
def link_title
"Commit: #{author_name} - #{title}"
end
def has_zero_stats?
stats.total.zero?
rescue
true
# Returns the commits title.
#
# Usually, the commit title is the first line of the commit message.
# In case this first line is longer than 80 characters, it is cut off
# after 70 characters and ellipses (`&hellp;`) are appended.
def title
title = safe_message
return no_commit_message if title.blank?
title_end = title.index(/\n/)
if (!title_end && title.length > 80) || (title_end && title_end > 80)
title[0..69] << "&hellip;".html_safe
else
title.split(/\n/, 2).first
end
end
# Returns the commits description
#
# cut off, ellipses (`&hellp;`) are prepended to the commit message.
def description
description = safe_message
title_end = description.index(/\n/)
if (!title_end && description.length > 80) || (title_end && title_end > 80)
"&hellip;".html_safe << description[70..-1]
else
description.split(/\n/, 2)[1].try(:chomp)
end
end
def method_missing(m, *args, &block)
@raw.send(m, *args, &block)
end
def respond_to?(method)
return true if @raw.respond_to?(method)
super
end
end

View file

@ -50,7 +50,7 @@ class GollumWiki
# Returns the last 30 Commit objects across the entire
# repository.
def recent_history
Commit.fresh_commits(wiki.repo, 30)
Gitlab::Git::Commit.fresh_commits(wiki.repo, 30)
end
# Finds a page within the repository based on a tile
@ -90,13 +90,17 @@ class GollumWiki
private
def create_repo!
if gitlab_shell.add_repository(path_with_namespace)
if init_repo(path_with_namespace)
Gollum::Wiki.new(path_to_repo)
else
raise CouldNotCreateWikiError
end
end
def init_repo(path_with_namespace)
gitlab_shell.add_repository(path_with_namespace)
end
def commit_details(action, message = nil, title = nil)
commit_message = message || default_message(action, title)
@ -114,5 +118,4 @@ class GollumWiki
def path_to_repo
@path_to_repo ||= File.join(Gitlab.config.gitlab_shell.repos_path, "#{path_with_namespace}.git")
end
end

View file

@ -152,7 +152,17 @@ class MergeRequest < ActiveRecord::Base
end
def commits
st_commits || []
if st_commits.present?
# check if merge request commits are valid
if st_commits.first.respond_to?(:short_id)
st_commits
else
# if commits are invalid - simply reload it from repo
reloaded_commits
end
else
[]
end
end
def probably_merged?
@ -169,9 +179,8 @@ class MergeRequest < ActiveRecord::Base
end
def unmerged_commits
self.project.repo.
self.project.repository.
commits_between(self.target_branch, self.source_branch).
map {|c| Commit.new(c)}.
sort_by(&:created_at).
reverse
end

View file

@ -8,7 +8,7 @@ module Network
attr_accessor :time, :spaces, :parent_spaces
def initialize(raw_commit, refs)
@commit = ::Commit.new(raw_commit)
@commit = Gitlab::Git::Commit.new(raw_commit)
@time = -1
@spaces = []
@parent_spaces = []

View file

@ -141,13 +141,7 @@ class Project < ActiveRecord::Base
end
def repository
if path
@repository ||= Repository.new(path_with_namespace, default_branch)
else
nil
end
rescue Grit::NoSuchPathError
nil
@repository ||= Repository.new(path_with_namespace, default_branch)
end
def saved?
@ -332,14 +326,14 @@ class Project < ActiveRecord::Base
end
def valid_repo?
repo
repository.exists?
rescue
errors.add(:path, "Invalid repository path")
false
end
def empty_repo?
!repository || repository.empty?
!repository.exists? || repository.empty?
end
def ensure_satellite_exists
@ -363,7 +357,7 @@ class Project < ActiveRecord::Base
end
def repo_exists?
@repo_exists ||= (repository && repository.branches.present?)
@repo_exists ||= repository.exists?
rescue
@repo_exists = false
end

View file

@ -1,170 +1,45 @@
class Repository
include Gitlab::Popen
attr_accessor :raw_repository
# Repository directory name with namespace direcotry
# Examples:
# gitlab/gitolite
# diaspora
#
attr_accessor :path_with_namespace
# Grit repo object
attr_accessor :repo
# Default branch in the repository
attr_accessor :root_ref
def initialize(path_with_namespace, root_ref = 'master')
@root_ref = root_ref || "master"
@path_with_namespace = path_with_namespace
# Init grit repo object
repo
def initialize(path_with_namespace, default_branch)
@raw_repository = Gitlab::Git::Repository.new(path_with_namespace, default_branch)
rescue Gitlab::Git::Repository::NoRepository
nil
end
def raw
repo
end
def path_to_repo
@path_to_repo ||= File.join(Gitlab.config.gitlab_shell.repos_path, "#{path_with_namespace}.git")
end
def repo
@repo ||= Grit::Repo.new(path_to_repo)
end
def commit(commit_id = nil)
Commit.find_or_first(repo, commit_id, root_ref)
end
def fresh_commits(n = 10)
Commit.fresh_commits(repo, n)
end
def commits_with_refs(n = 20)
Commit.commits_with_refs(repo, n)
end
def commits_since(date)
Commit.commits_since(repo, date)
end
def commits(ref, path = nil, limit = nil, offset = nil)
Commit.commits(repo, ref, path, limit, offset)
end
def last_commit_for(ref, path = nil)
commits(ref, path, 1).first
end
def commits_between(from, to)
Commit.commits_between(repo, from, to)
end
# Returns an Array of branch names
# sorted by name ASC
def branch_names
branches.map(&:name)
end
# Returns an Array of Branches
def branches
repo.branches.sort_by(&:name)
end
# Returns an Array of tag names
def tag_names
repo.tags.collect(&:name).sort.reverse
end
# Returns an Array of Tags
def tags
repo.tags.sort_by(&:name).reverse
end
# Returns an Array of branch and tag names
def ref_names
[branch_names + tag_names].flatten
end
def heads
@heads ||= repo.heads
end
def tree(fcommit, path = nil)
fcommit = commit if fcommit == :head
tree = fcommit.tree
path ? (tree / path) : tree
end
def has_commits?
!!commit
rescue Grit::NoSuchPathError
false
def exists?
raw_repository
end
def empty?
!has_commits?
raw_repository.empty?
end
# Discovers the default branch based on the repository's available branches
#
# - If no branches are present, returns nil
# - If one branch is present, returns its name
# - If two or more branches are present, returns the one that has a name
# matching root_ref (default_branch or 'master' if default_branch is nil)
def discover_default_branch
if branch_names.length == 0
nil
elsif branch_names.length == 1
branch_names.first
else
branch_names.select { |v| v == root_ref }.first
end
def commit(id = nil)
commit = raw_repository.commit(id)
commit = Commit.new(commit) if commit
commit
end
# Archive Project to .tar.gz
#
# Already packed repo archives stored at
# app_root/tmp/repositories/project_name/project_name-commit-id.tag.gz
#
def archive_repo(ref)
ref = ref || self.root_ref
commit = self.commit(ref)
return nil unless commit
# Build file path
file_name = self.path_with_namespace.gsub("/","_") + "-" + commit.id.to_s + ".tar.gz"
storage_path = Rails.root.join("tmp", "repositories")
file_path = File.join(storage_path, self.path_with_namespace, file_name)
# Put files into a directory before archiving
prefix = File.basename(self.path_with_namespace) + "/"
# Create file if not exists
unless File.exists?(file_path)
FileUtils.mkdir_p File.dirname(file_path)
file = self.repo.archive_to_file(ref, prefix, file_path)
end
file_path
def commits(ref, path = nil, limit = nil, offset = nil)
commits = raw_repository.commits(ref, path, limit, offset)
commits = Commit.decorate(commits) if commits.present?
commits
end
# Return repo size in megabytes
# Cached in redis
def size
Rails.cache.fetch(cache_key(:size)) do
size = popen('du -s', path_to_repo).first.strip.to_i
(size.to_f / 1024).round(2)
end
def commits_between(target, source)
commits = raw_repository.commits_between(target, source)
commits = Commit.decorate(commits) if commits.present?
commits
end
def expire_cache
Rails.cache.delete(cache_key(:size))
def method_missing(m, *args, &block)
raw_repository.send(m, *args, &block)
end
def cache_key(type)
"#{type}:#{path_with_namespace}"
def respond_to?(method)
return true if raw_repository.respond_to?(method)
super
end
end

View file

@ -26,4 +26,12 @@ class Tree
def empty?
data.blank?
end
def up_dir?
path.present?
end
def readme
@readme ||= contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }
end
end

View file

@ -79,14 +79,14 @@ class WikiPage
def version
return nil unless persisted?
@version ||= Commit.new(@page.version)
@version ||= Commit.new(Gitlab::Git::Commit.new(@page.version))
end
# Returns an array of Gitlab Commit instances.
def versions
return [] unless persisted?
@page.versions.map { |v| Commit.new(v) }
@page.versions.map { |v| Commit.new(Gitlab::Git::Commit.new(v)) }
end
# Returns the Date that this latest version was

View file

@ -46,18 +46,21 @@
%span.light ssh:
%strong
= link_to @project.ssh_url_to_repo
%li
%span.light fs:
%strong
= @repository.path_to_repo
- if @project.repository.exists?
%li
%span.light fs:
%strong
= @repository.path_to_repo
%li
%span.light last commit:
%strong
- if @repository
%li
%span.light last commit:
%strong
= last_commit(@project)
- else
never
- else
%li
%span.light repository:
%strong.cred
does not exist
%li
%span.light access:

View file

@ -6,7 +6,7 @@
%i.icon-angle-right
= link_to project_tree_path(@project, @ref) do
= @project.name
- @tree.breadcrumbs(6) do |link|
- tree_breadcrumbs(@tree, 6) do |link|
\/
%li= link
.clear
@ -22,13 +22,13 @@
%table
- current_line = 1
- @blame.each do |commit, lines|
- commit = CommitDecorator.decorate(Commit.new(commit))
- commit = Commit.new(commit)
%tr
%td.blame-commit
%span.commit
= link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id"
&nbsp;
= commit.author_link avatar: true, size: 16
= commit_author_link(commit, avatar: true, size: 16)
&nbsp;
= link_to_gfm truncate(commit.title, length: 20), project_commit_path(@project, commit.id), class: "row_title"
%td.lines.blame-numbers

View file

@ -24,14 +24,14 @@
.row
.span5
.author
= @commit.author_link avatar: true, size: 32
= commit_author_link(@commit, avatar: true, size: 32)
authored
%time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")}
#{time_ago_in_words(@commit.authored_date)} ago
- if @commit.different_committer?
.committer
&rarr;
= @commit.committer_link
= commit_committer_link(@commit)
committed
%time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")}
#{time_ago_in_words(@commit.committed_date)} ago

View file

@ -4,7 +4,7 @@
%strong= link_to "Browse Code »", project_tree_path(@project, commit), class: "right"
%p
= link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id"
= commit.author_link avatar: true, size: 24
= commit_author_link(commit, avatar: true, size: 24)
&nbsp;
= link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "row_title"

View file

@ -2,7 +2,7 @@
- if @path.present?
%ul.breadcrumb
= breadcrumbs
= commits_breadcrumbs
%div{id: dom_id(@project)}
#commits-list= render "commits"

View file

@ -16,7 +16,7 @@
%div.ui-box
%h5.title
Commits (#{@commits.count})
%ul.well-list= render @commits
%ul.well-list= render Commit.decorate(@commits)
- unless @diffs.empty?
%h4 Diff

View file

@ -1,4 +1,3 @@
- commit = CommitDecorator.decorate(commit)
%li.commit
%p
= link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"

View file

@ -4,7 +4,7 @@
.form-horizontal= render "shared/clone_panel"
.span4.pull-right
.pull-right
- unless @project.empty_repo?
- if @project.empty_repo?
- if can? current_user, :download_code, @project
= link_to archive_project_repository_path(@project), class: "btn-small btn grouped" do
%i.icon-download-alt

View file

@ -1,5 +1,4 @@
- commit = Commit.new(branch.commit)
- commit = CommitDecorator.decorate(commit)
- commit = Commit.new(Gitlab::Git::Commit.new(branch.commit))
%tr
%td
= link_to project_commits_path(@project, branch.name) do

View file

@ -1,5 +1,4 @@
- commit = update
- commit = CommitDecorator.new(commit)
%tr
%td
= link_to project_commits_path(@project, commit.head.name) do

View file

@ -7,8 +7,7 @@
%th Last commit
%th
- @tags.each do |tag|
- commit = Commit.new(tag.commit)
- commit = CommitDecorator.decorate(commit)
- commit = Commit.new(Gitlab::Git::Commit.new(tag.commit))
%tr
%td
%strong

View file

@ -3,7 +3,7 @@
%i.icon-angle-right
= link_to project_tree_path(@project, @ref) do
= @project.path
- tree.breadcrumbs(6) do |title, path|
- tree_breadcrumbs(tree, 6) do |title, path|
\/
%li
- if path
@ -27,7 +27,7 @@
%tr.tree-item
%td.tree-item-file-name
= image_tag "file_empty.png", size: '16x16'
= link_to "..", project_tree_path(@project, tree.up_dir_path)
= link_to "..", project_tree_path(@project, up_dir_path(tree))
%td
%td
%td

View file

@ -1,2 +1,2 @@
%span.tree_author= commit.author_link avatar: true
%span.tree_author= commit_author_link(commit, avatar: true)
= link_to_gfm truncate(commit.title, length: 80), project_commit_path(@project, commit.id), class: "tree-commit-link"

View file

@ -14,12 +14,13 @@
%th Format
%tbody
- @wiki.versions.each do |version|
- commit = CommitDecorator.new(version)
- commit = version
%tr
%td
= link_to project_wiki_path(@project, @wiki, version_id: commit.id) do
= commit.short_id
%td= commit.author_link avatar: true, size: 24
%td
= commit_author_link(commit, avatar: true, size: 24)
%td
= commit.title
%td

View file

@ -21,5 +21,5 @@
= wiki_page.created_at.to_s(:short) do
(#{time_ago_in_words(wiki_page.created_at)}
ago)
- commit = CommitDecorator.decorate(wiki_page.version)
%td= commit.author_link avatar: true, size: 24
%td
= commit_author_link(wiki_page.version, avatar: true, size: 24)

View file

@ -13,5 +13,4 @@
= preserve do
= render_wiki_content(@wiki)
- commit = CommitDecorator.new(@wiki.version)
%p.time Last edited by #{commit.author_link(avatar: true, size: 16)} #{time_ago_in_words @wiki.created_at} ago
%p.time Last edited by #{commit_author_link(@wiki.version, avatar: true, size: 16)} #{time_ago_in_words @wiki.created_at} ago