Project

General

Profile

Actions

Defect #33953

closed

Repository tab is not displayed if no repository is set as the main repository

Added by Jethro Yu about 4 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
SCM
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

I suggest that:

  • if there are any repositories in project, the "Repository Tab" button should show on main menu.
  • if no repository is set with "Main repository" and there is only one repository, the page should show the only repository by default.
  • if no repository is set with "Main repository" and there is multiple repositories, a blank page with Repositories sidebar should show.

Files

fixed-33953.patch (4.09 KB) fixed-33953.patch Yuichi HARADA, 2020-11-06 08:27

Related issues

Related to Redmine - Defect #14506: Multiple repositories not visible if main repository is emptyClosed

Actions
Actions #1

Updated by Go MAEDA about 4 years ago

  • Category changed from UI to SCM
  • Status changed from New to Confirmed
Actions #2

Updated by Go MAEDA about 4 years ago

  • Related to Defect #14506: Multiple repositories not visible if main repository is empty added
Actions #3

Updated by Yuichi HARADA almost 4 years ago

This issue and #14506 need to be resolved together. I created the following patch.

diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index b0108d531..4ceeaf014 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -321,7 +321,7 @@ class RepositoriesController < ApplicationController
     if params[:repository_id].present?
       @repository = @project.repositories.find_by_identifier_param(params[:repository_id])
     else
-      @repository = @project.repository
+      @repository = @project.repository || @project.repositories.first
     end
     (render_404; return false) unless @repository
     @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
diff --git a/lib/redmine.rb b/lib/redmine.rb
index de2993e13..470b5ae41 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -346,7 +346,7 @@ Redmine::MenuManager.map :project_menu do |menu|
   menu.push :repository,
             {:controller => 'repositories', :action => 'show',
              :repository_id => nil, :path => nil, :rev => nil},
-            :if => Proc.new {|p| p.repository && !p.repository.new_record?}
+            :if => Proc.new {|p| p.repositories.any?{|r| !r.new_record?}}
   menu.push :settings, {:controller => 'projects', :action => 'settings'},
             :last => true
 end
Actions #4

Updated by Go MAEDA almost 4 years ago

  • Target version set to Candidate for next major release
Actions #5

Updated by Go MAEDA over 2 years ago

  • Target version changed from Candidate for next major release to 5.1.0

Setting the target version to 5.1.0.

Actions #6

Updated by Go MAEDA over 2 years ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA
  • Target version changed from 5.1.0 to 5.0.3
  • Resolution set to Fixed

Committed the fix. Thank you for your contribution.

Actions #7

Updated by Go MAEDA over 2 years ago

  • Subject changed from Repository Tab will not showing if no repository is set as "Main repository" to Repository tab is not displayed if no repository is set as the main repository
Actions #8

Updated by Go MAEDA over 2 years ago

  • Status changed from Resolved to Closed
Actions #9

Updated by Marius BĂLTEANU about 2 years ago

  • Status changed from Closed to Reopened
Actions #11

Updated by Go MAEDA about 2 years ago

I think the following change fixes the issue that test_show_without_main_repository_should_display_first_repository randomly fails.

The objects should be sorted in the same way as done when rendering the sidebar of the repository tab (source:trunk/app/views/repositories/show.html.erb@21852#L64).

diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb
index 9ba464e67..e79ddda4f 100644
--- a/test/functional/repositories_controller_test.rb
+++ b/test/functional/repositories_controller_test.rb
@@ -200,7 +200,7 @@ class RepositoriesControllerTest < Redmine::RepositoryControllerTest
     repos.reload
     assert_equal false, repos.exists?(:is_default => true)

-    repository = repos.first
+    repository = repos.sort.first  # rubocop:disable Style/RedundantSort
     @request.session[:user_id] = 2

     get(:show, :params => {:id => 1})
Actions #12

Updated by Go MAEDA about 2 years ago

  • Status changed from Reopened to Resolved
Actions #13

Updated by Marius BĂLTEANU about 2 years ago

Thanks!

Actions #14

Updated by Go MAEDA about 2 years ago

  • Status changed from Resolved to Closed

Fixed random test failure in r21854 (trunk) and r21857 (5.0-stable).

Actions

Also available in: Atom PDF