diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index b508d28..ba6c6c2 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -4,18 +4,19 @@ class CommitsController < ApplicationController before_filter :project layout "project" + include ExtractsPath + # Authorize before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project - before_filter :load_refs, only: :index # load @branch, @tag & @ref - def index - @repo = project.repo + def show + @repo = @project.repo @limit, @offset = (params[:limit] || 40), (params[:offset] || 0) - @commits = @project.commits(@ref, params[:path], @limit, @offset) + @commits = @project.commits(@ref, @path, @limit, @offset) @commits = CommitDecorator.decorate(@commits) respond_to do |format| @@ -25,26 +26,6 @@ class CommitsController < ApplicationController end end - # def show - # result = CommitLoad.new(project, current_user, params).execute - - # @commit = result[:commit] - - # if @commit - # @suppress_diff = result[:suppress_diff] - # @note = result[:note] - # @line_notes = result[:line_notes] - # @notes_count = result[:notes_count] - # @comments_allowed = true - # else - # return git_not_found! - # end - - # if result[:status] == :huge_commit - # render "huge_commit" and return - # end - # end - def patch @commit = project.commit(params[:id]) @@ -55,11 +36,4 @@ class CommitsController < ApplicationController filename: "#{@commit.id}.patch" ) end - - protected - - def load_refs - @ref ||= params[:ref].presence || params[:branch].presence || params[:tag].presence - @ref ||= @ref || @project.try(:default_branch) || 'master' - end end diff --git a/app/views/commits/index.atom.builder b/app/views/commits/index.atom.builder deleted file mode 100644 index cca7045..0000000 --- a/app/views/commits/index.atom.builder +++ /dev/null @@ -1,23 +0,0 @@ -xml.instruct! -xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do - xml.title "Recent commits to #{@project.name}:#{@ref}" - xml.link :href => project_commits_url(@project, :atom, :ref => @ref), :rel => "self", :type => "application/atom+xml" - xml.link :href => project_commits_url(@project), :rel => "alternate", :type => "text/html" - xml.id project_commits_url(@project) - xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any? - - @commits.each do |commit| - xml.entry do - xml.id project_commit_url(@project, :id => commit.id) - xml.link :href => project_commit_url(@project, :id => commit.id) - xml.title truncate(commit.title, :length => 80) - xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") - xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email) - xml.author do |author| - xml.name commit.author_name - xml.email commit.author_email - end - xml.summary gfm(commit.description) - end - end -end diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml deleted file mode 100644 index 11ffdb6..0000000 --- a/app/views/commits/index.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -= render "head" - -- if params[:path] - %ul.breadcrumb - %li - %span.arrow - = link_to project_commits_path(@project) do - = @project.name - %span.divider - \/ - %li - %a{href: "#"}= params[:path].split("/").join(" / ") - -%div{id: dom_id(@project)} - #commits_list= render "commits" -.clear -.loading{ style: "display:none;"} - -- if @commits.count == @limit - :javascript - $(function(){ - CommitsList.init("#{@ref}", #{@limit}); - }); - diff --git a/app/views/commits/index.js.haml b/app/views/commits/index.js.haml deleted file mode 100644 index 797bc14..0000000 --- a/app/views/commits/index.js.haml +++ /dev/null @@ -1,3 +0,0 @@ -:plain - CommitsList.append(#{@commits.count}, "#{escape_javascript(render(partial: 'commits/commits'))}"); - diff --git a/app/views/commits/show.atom.builder b/app/views/commits/show.atom.builder new file mode 100644 index 0000000..cca7045 --- /dev/null +++ b/app/views/commits/show.atom.builder @@ -0,0 +1,23 @@ +xml.instruct! +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do + xml.title "Recent commits to #{@project.name}:#{@ref}" + xml.link :href => project_commits_url(@project, :atom, :ref => @ref), :rel => "self", :type => "application/atom+xml" + xml.link :href => project_commits_url(@project), :rel => "alternate", :type => "text/html" + xml.id project_commits_url(@project) + xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any? + + @commits.each do |commit| + xml.entry do + xml.id project_commit_url(@project, :id => commit.id) + xml.link :href => project_commit_url(@project, :id => commit.id) + xml.title truncate(commit.title, :length => 80) + xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email) + xml.author do |author| + xml.name commit.author_name + xml.email commit.author_email + end + xml.summary gfm(commit.description) + end + end +end diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml new file mode 100644 index 0000000..11ffdb6 --- /dev/null +++ b/app/views/commits/show.html.haml @@ -0,0 +1,24 @@ += render "head" + +- if params[:path] + %ul.breadcrumb + %li + %span.arrow + = link_to project_commits_path(@project) do + = @project.name + %span.divider + \/ + %li + %a{href: "#"}= params[:path].split("/").join(" / ") + +%div{id: dom_id(@project)} + #commits_list= render "commits" +.clear +.loading{ style: "display:none;"} + +- if @commits.count == @limit + :javascript + $(function(){ + CommitsList.init("#{@ref}", #{@limit}); + }); + diff --git a/app/views/commits/show.js.haml b/app/views/commits/show.js.haml new file mode 100644 index 0000000..797bc14 --- /dev/null +++ b/app/views/commits/show.js.haml @@ -0,0 +1,3 @@ +:plain + CommitsList.append(#{@commits.count}, "#{escape_javascript(render(partial: 'commits/commits'))}"); + diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index 11e632b..a46d59a 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -8,7 +8,7 @@ = link_to project_tree_path(@project, @project.root_ref) do Files %li{class: commit_tab_class} - = link_to "Commits", project_commits_path(@project) + = link_to "Commits", project_history_path(@project, @project.root_ref) %li{class: tab_class(:network)} = link_to "Network", graph_project_path(@project) diff --git a/config/routes.rb b/config/routes.rb index 708dd7d..01889bb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -159,13 +159,20 @@ Gitlab::Application.routes.draw do end end - resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} + # XXX: WIP + resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} + resources :commits, only: [:show], constraints: {id: /.+/}, as: 'history' + resources :blame, only: [:show], constraints: {id: /.+/} + resources :blob, only: [:show], constraints: {id: /.+/} + # resources :raw, only: [:show], constraints: {id: /.+/} + resources :tree, only: [:show], constraints: {id: /.+/} + match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/} - resources :commits, only: [:index, :show] do - member do - get :patch - end - end + # resources :commits, only: [:show], as: 'history' do + # member do + # get :patch + # end + # end resources :team, controller: 'team_members', only: [:index] resources :team_members @@ -184,13 +191,6 @@ Gitlab::Application.routes.draw do post :preview end end - - # XXX: WIP - resources :blame, only: [:show], constraints: {id: /.+/} - resources :blob, only: [:show], constraints: {id: /.+/} - # resources :raw, only: [:show], constraints: {id: /.+/} - resources :tree, only: [:show], constraints: {id: /.+/} - match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/} end root to: "dashboard#index" -- libgit2 0.21.2