diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 97dbb2bc0c0031f0e8d5619f02dc5a1989d42a33..aa6914414ceb6ace7ebaf1045bd25a80b3e3447b 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -11,6 +11,10 @@ class Projects::BranchesController < Projects::ApplicationController @branches = Kaminari.paginate_array(@repository.branches).page(params[:page]).per(30) end + def recent + @branches = @repository.recent_branches + end + def create @repository.add_branch(params[:branch_name], params[:ref]) diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 7e6c7016ecf32588d725b9212a56697c20a987b7..20e2a9311ee8dab7df8161b60ede132c31d23e7a 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -4,10 +4,6 @@ class Projects::RepositoriesController < Projects::ApplicationController before_filter :authorize_code_access! before_filter :require_non_empty_project - def show - @activities = @repository.commits_with_refs(20) - end - def stats @stats = Gitlab::Git::Stats.new(@repository.raw, @repository.root_ref) @graph = @stats.graph diff --git a/app/models/repository.rb b/app/models/repository.rb index cd33782a4cc18a5cdd05c97fc940921a51bd0cb8..a2fd91bbec1636a1328f2d8a3b3b54125b9557c9 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -49,6 +49,12 @@ class Repository tags.find { |tag| tag.name == name } end + def recent_branches(limit = 20) + branches.sort do |a, b| + a.commit.committed_date <=> b.commit.committed_date + end[0..limit] + end + def add_branch(branch_name, ref) Rails.cache.delete(cache_key(:branch_names)) diff --git a/app/views/projects/repositories/_filter.html.haml b/app/views/projects/branches/_filter.html.haml similarity index 80% rename from app/views/projects/repositories/_filter.html.haml rename to app/views/projects/branches/_filter.html.haml index 660d9d25a35a6116d2361ba9842af017e235c2f5..7ea11a74a2b8ca6f1ea61f2593d03ab7c221410c 100644 --- a/app/views/projects/repositories/_filter.html.haml +++ b/app/views/projects/branches/_filter.html.haml @@ -1,6 +1,6 @@ %ul.nav.nav-pills.nav-stacked - = nav_link(path: 'repositories#show') do - = link_to 'Recent', project_repository_path(@project) + = nav_link(path: 'branches#recent') do + = link_to 'Recent', recent_project_branches_path(@project) = nav_link(path: 'protected_branches#index') do = link_to project_protected_branches_path(@project) do Protected diff --git a/app/views/projects/branches/index.html.haml b/app/views/projects/branches/index.html.haml index 4cfafe1a7af41a77bcf7540977a76b1bd2de5713..7a0eda6408ae8257191b43002aa1a4510d208b8e 100644 --- a/app/views/projects/branches/index.html.haml +++ b/app/views/projects/branches/index.html.haml @@ -1,7 +1,7 @@ = render "projects/commits/head" .row .span3 - = render "projects/repositories/filter" + = render "filter" .span9 - unless @branches.empty? %ul.bordered-list diff --git a/app/views/projects/branches/recent.html.haml b/app/views/projects/branches/recent.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..6cafb47364b9ae7831b7a45916d4e76d811e8f7a --- /dev/null +++ b/app/views/projects/branches/recent.html.haml @@ -0,0 +1,8 @@ += render "projects/commits/head" +.row + .span3 + = render "filter" + .span9 + %ul.bordered-list + - @branches.each do |branch| + = render "projects/branches/branch", branch: branch diff --git a/app/views/projects/commits/_head.html.haml b/app/views/projects/commits/_head.html.haml index 06d69eb5f750a14480343defa12acbc5752a8924..c16abac7f171c0860f706348c9899ac619f2424f 100644 --- a/app/views/projects/commits/_head.html.haml +++ b/app/views/projects/commits/_head.html.haml @@ -7,7 +7,7 @@ = link_to 'Compare', project_compare_index_path(@project) = nav_link(html_options: {class: branches_tab_class}) do - = link_to project_repository_path(@project) do + = link_to recent_project_branches_path(@project) do Branches %span.badge= @repository.branches.length diff --git a/app/views/projects/protected_branches/index.html.haml b/app/views/projects/protected_branches/index.html.haml index 9cadb6fb1263b5629ad732b38fb2a73558cefc95..8930ec4b30a8022784a22a6348214a494857dfb5 100644 --- a/app/views/projects/protected_branches/index.html.haml +++ b/app/views/projects/protected_branches/index.html.haml @@ -1,7 +1,7 @@ = render "projects/commits/head" .row .span3 - = render "projects/repositories/filter" + = render "projects/branches/filter" .span9 .alert.alert-info %p Protected branches designed to prevent push for all except #{link_to "masters", help_permissions_path, class: "vlink"}. diff --git a/app/views/projects/repositories/show.html.haml b/app/views/projects/repositories/show.html.haml deleted file mode 100644 index 611d0eddc4c12de9bcb09bdeb74cc19de7e882b4..0000000000000000000000000000000000000000 --- a/app/views/projects/repositories/show.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -= render "projects/commits/head" -.row - .span3 - = render "filter" - .span9 - %ul.bordered-list - - @activities.each do |update| - = render "projects/branches/branch", branch: update.head - diff --git a/config/routes.rb b/config/routes.rb index d303a57d3047a418abb4ac1307a5f74d04122430..c83e18ce4f0726b13e3aaa298c17a2f4219d35ee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -225,8 +225,13 @@ Gitlab::Application.routes.draw do end end + resources :branches, only: [:index, :new, :create, :destroy] do + collection do + get :recent + end + end + resources :tags, only: [:index, :new, :create, :destroy] - resources :branches, only: [:index, :new, :create, :destroy] resources :protected_branches, only: [:index, :create, :destroy] resources :refs, only: [] do