Index: app/controllers/repositories_controller.rb =================================================================== --- app/controllers/repositories_controller.rb (revision 5642) +++ app/controllers/repositories_controller.rb (working copy) @@ -42,6 +42,7 @@ end if request.post? && @repository @repository.attributes = params[:repository] + @repository.include_in_scheduled_fetch = !params[:include_in_scheduled_fetch].nil? @repository.save end render(:update) do |page| Index: app/models/repository.rb =================================================================== --- app/models/repository.rb (revision 5642) +++ app/models/repository.rb (working copy) @@ -211,21 +211,39 @@ encoding.blank? ? 'UTF-8' : encoding end - # Fetches new changesets for all repositories of active projects - # Can be called periodically by an external script - # eg. ruby script/runner "Repository.fetch_changesets" - def self.fetch_changesets + # Fetches new changsets for all repositories of active projects + # When fetch_all is true, all repositories will be processed, but when it is false, + # only those with the 'include_in_scheduled_fetch' flag set will be retrieved + def self.do_fetch_changesets(fetch_all) Project.active.has_module(:repository).find(:all, :include => :repository).each do |project| if project.repository begin - project.repository.fetch_changesets - rescue Redmine::Scm::Adapters::CommandFailed => e - logger.error "scm: error during fetching changesets: #{e.message}" + if (project.repository.include_in_scheduled_fetch? or fetch_all) + begin + project.repository.fetch_changesets + rescue Redmine::Scm::Adapters::CommandFailed => e + logger.error "scm: error during fetch of changesets: #{e.message}" + end + end end end end end + # Fetches new changesets for all repositories of active projects + # Can be called periodically by an external script + # eg. ruby script/runner "Repository.fetch_changesets" + def self.fetch_changesets + self.do_fetch_changesets(true) + end + + # Fetches new changesets for all repositories of active projects which have the 'include_in_scheduled_fetch' flag set + # Should be called periodically by an external script + # eg. ruby script/runner "Repository.scheduled_fetch_changesets" + def self.scheduled_fetch_changesets + self.do_fetch_changesets(false) + end + # scan changeset comments to find related and fixed issues for all repositories def self.scan_changesets_for_issue_ids find(:all).each(&:scan_changesets_for_issue_ids) Index: app/views/projects/settings/_repository.rhtml =================================================================== --- app/views/projects/settings/_repository.rhtml (revision 5642) +++ app/views/projects/settings/_repository.rhtml (working copy) @@ -6,6 +6,7 @@ <%= error_messages_for 'repository' %>
+

<%= label_tag('include_in_scheduled_fetch', l(:label_include_in_scheduled_fetch)) %><%= check_box_tag 'include_in_scheduled_fetch', 1, @repository && @repository.include_in_scheduled_fetch? %>

<%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository) %> <% if @repository %> Index: config/locales/en-GB.yml =================================================================== --- config/locales/en-GB.yml (revision 5642) +++ config/locales/en-GB.yml (working copy) @@ -804,6 +804,7 @@ label_project_copy_notifications: Send email notifications during the project copy label_principal_search: "Search for user or group:" label_user_search: "Search for user:" + label_include_in_scheduled_fetch: "Include in scheduled fetch" button_login: Login button_submit: Submit Index: config/locales/en.yml =================================================================== --- config/locales/en.yml (revision 5642) +++ config/locales/en.yml (working copy) @@ -819,6 +819,7 @@ label_issues_visibility_all: All issues label_issues_visibility_public: All non private issues label_issues_visibility_own: Issues created by or assigned to the user + label_include_in_scheduled_fetch: "Include in scheduled fetch" button_login: Login button_submit: Submit Index: db/migrate/20110504001300_add_include_repos_in_scheduled_fetch_flag.rb =================================================================== --- db/migrate/20110504001300_add_include_repos_in_scheduled_fetch_flag.rb (revision 0) +++ db/migrate/20110504001300_add_include_repos_in_scheduled_fetch_flag.rb (revision 0) @@ -0,0 +1,9 @@ +class AddIncludeReposInScheduledFetchFlag < ActiveRecord::Migration + def self.up + add_column :repositories, :include_in_scheduled_fetch, :boolean, :default => false, :null => false + end + + def self.down + drop_column :repositories, :include_in_scheduled_fetch + end +end \ No newline at end of file Index: lib/tasks/scheduled_fetch_changesets.rake =================================================================== --- lib/tasks/scheduled_fetch_changesets.rake (revision 0) +++ lib/tasks/scheduled_fetch_changesets.rake (revision 0) @@ -0,0 +1,24 @@ +# redMine - project management software +# Copyright (C) 2006-2008 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +desc 'Scheduled fetch changesets from the repositories' + +namespace :redmine do + task :scheduled_fetch_changesets => :environment do + Repository.scheduled_fetch_changesets + end +end