[refs #90] commits tab

This commit is contained in:
Alexander Machehin 2012-05-25 16:48:44 +06:00
parent 4f1d23a2a4
commit df610931d7
7 changed files with 26 additions and 21 deletions

View File

@ -1,6 +1,5 @@
# -*- encoding : utf-8 -*-
class Projects::Git::CommitsController < Projects::Git::BaseController
helper_method :split_commits_by_date
def index
@branch_name = params[:treeish] || @project.default_branch
@ -25,18 +24,4 @@ class Projects::Git::CommitsController < Projects::Git::BaseController
format.patch { render :text => (@commit.to_patch rescue ''), :content_type => "text/plain" }
end
end
protected
def split_commits_by_date(commits)
res = commits.sort{|x, y| y.authored_date <=> x.authored_date}.inject({}) do |h, commit|
dt = commit.authored_date
h[dt.year] ||= {}
h[dt.year][dt.month] ||= {}
h[dt.year][dt.month][dt.day] ||= []
h[dt.year][dt.month][dt.day] << commit
h
end
return res
end
end

View File

@ -25,7 +25,10 @@ class Projects::PullRequestsController < Projects::BaseController
repo = Git::Repository.new(@pull.path)
@base_commit = repo.commits(@pull.base_ref).first
@head_commit = repo.commits(@pull.head_branch).first
@diff = Grit::Repo.new(@pull.path).diff @base_commit, @head_commit
repo = Grit::Repo.new(@pull.path)
@diff = repo.diff @base_commit, @head_commit
@commits = repo.commits_between @base_commit, @head_commit
end
end
@ -68,7 +71,9 @@ class Projects::PullRequestsController < Projects::BaseController
@base_commit = repo.commits(@pull.base_ref).first
@head_commit = repo.commits(@pull.head_branch).first
@diff = Grit::Repo.new(@pull.path).diff @base_commit, @head_commit
repo = Grit::Repo.new(@pull.path)
@diff = repo.diff @base_commit, @head_commit
@commits = repo.commits_between @base_commit, @head_commit
end
def autocomplete_base_project_name

View File

@ -77,4 +77,17 @@ module GitHelper
grouped_options_for_select(res, current)
end
def split_commits_by_date(commits)
res = commits.sort{|x, y| y.authored_date <=> x.authored_date}.inject({}) do |h, commit|
dt = commit.authored_date
h[dt.year] ||= {}
h[dt.year][dt.month] ||= {}
h[dt.year][dt.month][dt.day] ||= []
h[dt.year][dt.month][dt.day] << commit
h
end
return res
end
end

View File

@ -48,7 +48,8 @@
= render :partial => 'commit_diff', :collection => @diff
- rescue Grit::Git::GitTimeout
%p= t 'layout.git.repositories.commit_diff_too_big'
#commits.tab-pane ...
#commits.tab-pane
= render :partial => 'projects/git/commits/commits', :object => @commits
:javascript
$(function () {

View File

@ -39,7 +39,8 @@
= render :partial => 'commit_diff', :collection => @diff
- rescue Grit::Git::GitTimeout
%p= t 'layout.git.repositories.commit_diff_too_big'
#commits.tab-pane ...
#commits.tab-pane
= render :partial => 'projects/git/commits/commits', :object => @commits
:javascript
$(function () {

View File

@ -19,7 +19,7 @@ en:
tabs:
discussion: Discussion
diff: Diff
Commits: Commits
commits: Commits
flash:
pull_request:

View File

@ -19,7 +19,7 @@ ru:
tabs:
discussion: Дискуссия
diff: Diff
Commits: Коммиты
commits: Коммиты
flash:
pull_request: