プロジェクト

全般

プロフィール

Vote #81817

未完了

Clicking the "New repository" button causes a 404 error

Admin Redmine さんが約2年前に追加. 約2年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
SCM_3
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
3
version_id:
0
issue_org_id:
36581
author_id:
332
assigned_to_id:
0
comments:
2
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

When you attempt to create a new repository setting by clicking the "New repository" button in the Repositories tab of the project settings, you may encounter a 404 error.

The error occurs when no SCM is enabled in Administration > Settings > Repositories > Enabled SCM, at @RepositoriesController::build_new_repository_from_params@.


  def build_new_repository_from_params
    scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
    unless @repository = Repository.factory(scm)
      render_404
      return
    end

With a 404 error, it is difficult for users to know how to resolve it. I think Redmine should output a more informative error message.


journals

If there is no enabled SCM, how about show the message instead of the "New repository" link?
I think it would be even better if, in addition to this, it returns error_enabled_scm_not_exist instead of render_404.

<pre><code class="diff">
diff --git a/app/views/projects/settings/_repositories.html.erb b/app/views/projects/settings/_repositories.html.erb
index 8ae2ba25bf..5005e96971 100644
--- a/app/views/projects/settings/_repositories.html.erb
+++ b/app/views/projects/settings/_repositories.html.erb
@@ -1,5 +1,9 @@
<% if User.current.allowed_to?(:manage_repository, @project) %>
- <p><%= link_to l(:label_repository_new), new_project_repository_path(@project), :class => 'icon icon-add' %></p>
+ <% if (Redmine::Scm::Base.all & Setting.enabled_scm).present? %>
+ <p><%= link_to l(:label_repository_new), new_project_repository_path(@project), :class => 'icon icon-add' %></p>
+ <% else %>
+ <div class="flash warning"><%= l(:error_enabled_scm_not_exist) %></div>
+ <% end %>
<% end %>

<% if @project.repositories.any? %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 2378e56d5b..69ec6b27a0 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -196,6 +196,7 @@ en:
notice_invalid_watcher: "Invalid watcher: User will not receive any notifications because it does not have access to view this object."

error_can_t_load_default_data: "Default configuration could not be loaded: %{value}"
+ error_enabled_scm_not_exist: Enabled SCM does not exist.
error_scm_not_found: "The entry or revision was not found in the repository."
error_scm_command_failed: "An error occurred when trying to access the repository: %{value}"
error_scm_annotate: "The entry does not exist or cannot be annotated."
</code></pre>
--------------------------------------------------------------------------------
Mizuki ISHIKAWA wrote:
> If there is no enabled SCM, how about show the message instead of the "New repository" link?
> I think it would be even better if, in addition to this, it returns error_enabled_scm_not_exist instead of render_404.
>
> [...]

Thank you for your suggestion. But I see a minor problem in the patch that you will see "The page you were trying to access doesn't exist or has been removed" even after applying the patch by directly accessing /projects/ecookbook/repositories/new. In order to avoid this, I think it is better to check if any SCM is enabled in a controller than a view like this. Also, the message in the original patch is obvious and a bit obtrusive for me.

The following is my suggestion.

<pre><code class="diff">
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index fe55e1770..dce923cab 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -312,7 +312,11 @@ class RepositoriesController < ApplicationController
private

def build_new_repository_from_params
- scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
+ if (available_scms = Redmine::Scm::Base.all & Setting.enabled_scm).empty?
+ render_error :message => :error_scm_not_enabled, :status => 403
+ return
+ end
+ scm = params[:repository_scm] || available_scms.first
unless @repository = Repository.factory(scm)
render_404
return
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 2378e56d5..7eaac9c9b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -197,6 +197,7 @@ en:

error_can_t_load_default_data: "Default configuration could not be loaded: %{value}"
error_scm_not_found: "The entry or revision was not found in the repository."
+ error_scm_not_enabled: "There is no enabled SCM."
error_scm_command_failed: "An error occurred when trying to access the repository: %{value}"
error_scm_annotate: "The entry does not exist or cannot be annotated."
error_scm_annotate_big_text_file: "The entry cannot be annotated, as it exceeds the maximum text file size."
</code></pre>

--------------------------------------------------------------------------------

Admin Redmine さんが約2年前に更新

  • カテゴリSCM_3 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0