Project

General

Profile

Patch #8294 » 20110504-IncludeReposInScheduledFetch.patch

IncludeReposInScheduledFetch Path File - Built against revision r5642 - Christina Louise Warne, 2011-05-05 03:36

View differences:

app/controllers/repositories_controller.rb (working copy)
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|
app/models/repository.rb (working copy)
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)
app/views/projects/settings/_repository.rhtml (working copy)
<%= error_messages_for 'repository' %>
<div class="box tabular">
<p><%= 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? %></p>
<p>
<%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository) %>
<% if @repository %>
config/locales/en-GB.yml (working copy)
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
config/locales/en.yml (working copy)
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
db/migrate/20110504001300_add_include_repos_in_scheduled_fetch_flag.rb (revision 0)
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
lib/tasks/scheduled_fetch_changesets.rake (revision 0)
# 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
(1-1/2)