]> source.dussan.org Git - redmine.git/commitdiff
Allow manually fetching changesets (#8875).
authorGo MAEDA <maeda@farend.jp>
Thu, 11 Mar 2021 07:00:09 +0000 (07:00 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 11 Mar 2021 07:00:09 +0000 (07:00 +0000)
Patch by Yuichi HARADA.

git-svn-id: http://svn.redmine.org/redmine/trunk@20772 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/repositories_controller.rb
app/views/repositories/_navigation.html.erb
config/locales/en.yml
config/routes.rb
lib/redmine.rb
test/functional/repositories_controller_test.rb
test/integration/routing/repositories_test.rb

index b0108d5318137700b5f076499bebf1ee3946d72f..3274b942acfacb5cff195b39621f4d91781d19f5 100644 (file)
@@ -100,6 +100,11 @@ class RepositoriesController < ApplicationController
 
   alias_method :browse, :show
 
+  def fetch_changesets
+    @repository.fetch_changesets if @project.active? && @path.empty? && !Setting.autofetch_changesets?
+    show
+  end
+
   def changes
     @entry = @repository.entry(@path, @rev)
     (show_error_not_found; return) unless @entry
index 730cec42f1b32d94537c15f21a5ff2a4c65227af..b37631a81e828c9c673c3e9b901976f7685b932a 100644 (file)
@@ -19,6 +19,9 @@
   <%= link_to_if_authorized l(:label_settings),
             {:controller => 'projects', :action => 'settings', :id => @project, :tab => 'repositories'},
             :class => 'icon icon-settings' if User.current.allowed_to?(:manage_repository, @project) %>
+  <%= link_to l(:button_fetch_changesets),
+              {:action => :fetch_changesets, :id => @project, :repository_id => @repository.identifier_param},
+              :class => 'icon icon-reload', :method => :post if User.current.allowed_to?(:manage_repository, @project) && !Setting.autofetch_changesets? %>
 <% end %>
 
 <%= form_tag({:action => controller.action_name,
index 979417a32ec1ee83ed53ced0f259463c4d2add8f..8009fe5f3a6b0228bae6b6d9f307abd850fdb09f 100644 (file)
@@ -1146,6 +1146,7 @@ en:
   button_copy: Copy
   button_copy_and_follow: Copy and follow
   button_annotate: Annotate
+  button_fetch_changesets: Fetch commits
   button_update: Update
   button_configure: Configure
   button_quote: Quote
index cb6f7ec34a323a7ad49181491980740fe1aa8ef4..40c1d5f50593df40f99551ece95087844fe8574c 100644 (file)
@@ -268,6 +268,7 @@ Rails.application.routes.draw do
   # repositories routes
   get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
   get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
+  post 'projects/:id/repository/:repository_id/fetch_changesets', :to => 'repositories#fetch_changesets'
 
   get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
   get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
index 142b6088803dd3aec02ba3816678730bcdde1060..551ea4005123a208c41ba9f53695262587596691 100644 (file)
@@ -178,7 +178,7 @@ Redmine::AccessControl.map do |map|
     map.permission :browse_repository, {:repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph]}, :read => true
     map.permission :commit_access, {}
     map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]}
-    map.permission :manage_repository, {:projects => :settings, :repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member
+    map.permission :manage_repository, {:projects => :settings, :repositories => [:new, :create, :edit, :update, :committers, :destroy, :fetch_changesets]}, :require => :member
   end
 
   map.project_module :boards do |map|
index 0668cea43a465485e45bc4ec358a64e288523e94..4f20670267e09d7627cc209469f2ab5acb56fb07 100644 (file)
@@ -203,6 +203,23 @@ class RepositoriesControllerTest < Redmine::RepositoryControllerTest
       assert_response :success
       assert_select 'input[value="View differences"]', :count => 0
     end
+
+    def test_fetch_changesets
+      @request.session[:user_id] = 2
+      role = Role.find(1)
+
+      with_settings :autofetch_changesets => '0' do
+        role.add_permission! :manage_repository
+        Repository::Subversion.any_instance.expects(:fetch_changesets).once
+        post(:fetch_changesets, :params => {:id => 1, :repository_id => 10})
+        assert_response :success
+
+        role.remove_permission! :manage_repository
+        Repository::Subversion.any_instance.expects(:fetch_changesets).never
+        post(:fetch_changesets, :params => {:id => 1, :repository_id => 10})
+        assert_response :forbidden
+      end
+    end
   end
 
   def test_revisions
index 74ecf4c1b67d9e80c8bc0749a9370bc0838b8885..6a9ffc84e800631625a2277d9da0c11fd21a0905 100644 (file)
@@ -70,6 +70,10 @@ class RoutingRepositoriesTest < Redmine::RoutingTest
     end
   end
 
+  def test_repositories_fetch_changesets_with_repository_id
+    should_route 'POST /projects/foo/repository/bar/fetch_changesets' => 'repositories#fetch_changesets', :id => 'foo', :repository_id => 'bar'
+  end
+
   def test_repositories_non_revisions_path_with_repository_id
     should_route 'GET /projects/foo/repository/svn/changes' => 'repositories#changes', :id => 'foo', :repository_id => 'svn', :format => 'html'