8875-manually-fetching-changesets.patch

Yuichi HARADA, 2020-10-28 06:02

Download (4.51 KB)

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' if User.current.allowed_to?(:browse_repository, @project) && !Setting.autofetch_changesets? %>
22 25
<% end %>
23 26

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

  
266 267
  get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
267 268
  get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
lib/redmine.rb
175 175

  
176 176
  map.project_module :repository do |map|
177 177
    map.permission :view_changesets, {:repositories => [:show, :revisions, :revision]}, :read => true
178
    map.permission :browse_repository, {:repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph]}, :read => true
178
    map.permission :browse_repository, {:repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph, :fetch_changesets]}, :read => true
179 179
    map.permission :commit_access, {}
180 180
    map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]}
181 181
    map.permission :manage_repository, {:projects => :settings, :repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member
test/functional/repositories_controller_test.rb
205 205
    end
206 206
  end
207 207

  
208
  def test_fetch_changesets_with_autofetch_changesets_disabled_and_browse_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! :browse_repository
214
      Repository::Subversion.any_instance.expects(:fetch_changesets).once
215
      get(:fetch_changesets, :params => {:id => 1, :repository_id => 10})
216
      assert_response :success
217

  
218
      role.remove_permission! :browse_repository
219
      Repository::Subversion.any_instance.expects(:fetch_changesets).never
220
      get(: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,