Use Gitlab::Git:: for git features across application

This commit is contained in:
Dmitriy Zaporozhets 2013-04-01 16:04:35 +03:00
parent bb06e905ef
commit 49b024f5f5
11 changed files with 32 additions and 64 deletions

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

@ -8,12 +8,12 @@ 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 = []
end

View file

@ -8,6 +8,10 @@ class Commit
#
DIFF_SAFE_SIZE = 100
def self.decorate(commits)
commits.map { |c| self.new(c) }
end
attr_accessor :raw
def initialize(raw_commit)

View file

@ -114,5 +114,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

@ -13,13 +13,13 @@ class Repository
def commits(ref, path = nil, limit = nil, offset = nil)
commits = raw_repository.commits(ref, path, limit, offset)
commits = decorate_commits(commits) if commits.present?
commits = Commit.decorate(commits) if commits.present?
commits
end
def commits_between(target, source)
commits = raw_repository.commits_between(target, source)
commits = decorate_commits(commits) if commits.present?
commits = Commit.decorate(commits) if commits.present?
commits
end
@ -32,10 +32,4 @@ class Repository
super
end
protected
def decorate_commits(commits)
commits.map { |c| Commit.new(c) }
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

@ -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

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

@ -13,5 +13,4 @@
= preserve do
= render_wiki_content(@wiki)
- commit = Commit.new(@wiki.version)
%p.time Last edited by #{commit_author_link(commit, 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