Project

General

Profile

Patch #31987 » changesets.rake.patch

Go MAEDA, 2021-03-28 16:56

View differences:

lib/tasks/changesets.rake
# Redmine - project management software
# Copyright (C) 2006-2021 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.
namespace :redmine do
namespace :changesets do
desc 'Fetch changesets from the repositories'
task :fetch => :environment do
Repository.fetch_changesets
end
desc 'Sync all revisions in repositories related with all active project.'
task :reload => :environment do
Project.active.has_module(:repository).find_each do |project|
project.repositories.find_each do |repository|
detail = [
"PJ-ID #{repository.project_id}",
"Identifier #{repository.identifier}",
"URL #{repository.url}",
].join(", ")
changesets = repository.changesets
puts("Sync revisions: #{changesets.count}: #{detail}")
latest_changeset = changesets.first
changeset = latest_changeset
while changeset
revisions = repository.scm.revisions(nil,
changeset.identifier,
changeset.identifier)
revisions.each do |revision|
changeset.committer =
Changeset.to_utf8(revision.author,
repository.repo_log_encoding)
changeset.comments =
Changeset.normalize_comments(revision.message,
repository.repo_log_encoding)
changeset.user =
repository.find_committer_user(changeset.committer)
next unless changeset.changed?
changeset.issues = []
changeset.scan_for_issues
if changeset.save
puts("Sync revision: #{changeset.identifier}, #{detail}")
else
puts("Failed to sync revision: " +
"#{changeset.identifier}, #{detail}: " +
changeset.errors.to_s)
end
end
changeset = changeset.previous
end
end
end
end
end
end
lib/tasks/redmine.rake
desc 'Fetch changesets from the repositories'
task :fetch_changesets => :environment do
Repository.fetch_changesets
warn 'redmine:fetch_changesets is deprecated. Use redmine:changesets:fetch instead.'
Rake::Task["redmine:changesets:fetch"].invoke
end
desc 'Migrates and copies plugins assets.'
(3-3/3)