Project

General

Profile

Feature #8875 » 8875-manually-fetching-changesets-v3.patch

Yuichi HARADA, 2021-01-19 08:07

View differences:

app/controllers/repositories_controller.rb
100 100

  
101 101
  alias_method :browse, :show
102 102

  
103
  def fetch_changesets
104
    @repository.fetch_changesets if @project.active? && @path.empty? && !Setting.autofetch_changesets?
105
    show
106
  end
107

  
103 108
  def changes
104 109
    @entry = @repository.entry(@path, @rev)
105 110
    (show_error_not_found; return) unless @entry
app/views/repositories/_navigation.html.erb
19 19
  <%= link_to_if_authorized l(:label_settings),
20 20
            {:controller => 'projects', :action => 'settings', :id => @project, :tab => 'repositories'},
21 21
            :class => 'icon icon-settings' if User.current.allowed_to?(:manage_repository, @project) %>
22
  <%= link_to l(:label_fetch_changesets),
23
              {:action => :fetch_changesets, :id => @project, :repository_id => @repository.identifier_param},
24
              :class => 'icon icon-reload', :method => :post if User.current.allowed_to?(:manage_repository, @project) && !Setting.autofetch_changesets? %>
22 25
<% end %>
23 26

  
24 27
<%= form_tag({:action => controller.action_name,
config/locales/en.yml
803 803
  label_repository: Repository
804 804
  label_repository_new: New repository
805 805
  label_repository_plural: Repositories
806
  label_fetch_changesets: Fetch changesets
806 807
  label_browse: Browse
807 808
  label_branch: Branch
808 809
  label_tag: Tag
config/routes.rb
265 265
  # repositories routes
266 266
  get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
267 267
  get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
268
  post 'projects/:id/repository/:repository_id/fetch_changesets', :to => 'repositories#fetch_changesets'
268 269

  
269 270
  get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
270 271
  get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
lib/redmine.rb
178 178
    map.permission :browse_repository, {:repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph]}, :read => true
179 179
    map.permission :commit_access, {}
180 180
    map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]}
181
    map.permission :manage_repository, {:projects => :settings, :repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member
181
    map.permission :manage_repository, {:projects => :settings, :repositories => [:new, :create, :edit, :update, :committers, :destroy, :fetch_changesets]}, :require => :member
182 182
  end
183 183

  
184 184
  map.project_module :boards do |map|
test/functional/repositories_controller_test.rb
205 205
    end
206 206
  end
207 207

  
208
  def test_fetch_changesets_with_autofetch_changesets_disabled_and_manage_repository_permission_should_fetch_changesets
209
    @request.session[:user_id] = 2
210
    role = Role.find(1)
211

  
212
    with_settings :autofetch_changesets => '0' do
213
      role.add_permission! :manage_repository
214
      Repository::Subversion.any_instance.expects(:fetch_changesets).once
215
      post(:fetch_changesets, :params => {:id => 1, :repository_id => 10})
216
      assert_response :success
217

  
218
      role.remove_permission! :manage_repository
219
      Repository::Subversion.any_instance.expects(:fetch_changesets).never
220
      post(:fetch_changesets, :params => {:id => 1, :repository_id => 10})
221
      assert_response :forbidden
222
    end
223
  end
224

  
208 225
  def test_revisions
209 226
    get(
210 227
      :revisions,
test/integration/routing/repositories_test.rb
70 70
    end
71 71
  end
72 72

  
73
  def test_repositories_fetch_changesets_with_repository_id
74
    should_route 'POST /projects/foo/repository/bar/fetch_changesets' => 'repositories#fetch_changesets', :id => 'foo', :repository_id => 'bar'
75
  end
76

  
73 77
  def test_repositories_non_revisions_path_with_repository_id
74 78
    should_route 'GET /projects/foo/repository/svn/changes' => 'repositories#changes', :id => 'foo', :repository_id => 'svn', :format => 'html'
75 79

  
(6-6/6)