Patch #31987 » changesets.rake.patch
lib/tasks/changesets.rake | ||
---|---|---|
1 |
namespace :redmine do |
|
2 |
namespace :changesets do |
|
3 |
desc 'Sync all revisions in repositories related with all active project.' |
|
4 |
task :reload => :environment do |
|
5 |
Project.active.has_module(:repository).find_each do |project| |
|
6 |
project.repositories.find_each do |repository| |
|
7 |
detail = [ |
|
8 |
"PJ-ID #{repository.project_id}", |
|
9 |
"Identifier #{repository.identifier}", |
|
10 |
"URL #{repository.url}", |
|
11 |
].join(", ") |
|
12 |
changesets = repository.changesets |
|
13 |
puts("Sync revisions: #{changesets.count}: #{detail}") |
|
14 |
latest_changeset = changesets.first |
|
15 |
changeset = latest_changeset |
|
16 |
while changeset |
|
17 |
revisions = repository.scm.revisions(nil, |
|
18 |
changeset.identifier, |
|
19 |
changeset.identifier) |
|
20 |
revisions.each do |revision| |
|
21 |
changeset.committer = |
|
22 |
Changeset.to_utf8(revision.author, |
|
23 |
repository.repo_log_encoding) |
|
24 |
changeset.comments = |
|
25 |
Changeset.normalize_comments(revision.message, |
|
26 |
repository.repo_log_encoding) |
|
27 |
changeset.user = |
|
28 |
repository.find_committer_user(changeset.committer) |
|
29 |
next unless changeset.changed? |
|
30 |
changeset.issues = [] |
|
31 |
changeset.scan_for_issues |
|
32 |
if changeset.save |
|
33 |
puts("Sync revision: #{changeset.identifier}, #{detail}") |
|
34 |
else |
|
35 |
puts("Failed to sync revision: " + |
|
36 |
"#{changeset.identifier}, #{detail}: " + |
|
37 |
"#{changeset.errors}") |
|
38 |
end |
|
39 |
end |
|
40 |
changeset = changeset.previous |
|
41 |
end |
|
42 |
end |
|
43 |
end |
|
44 |
end |
|
45 |
end |
|
46 |
end |
|
47 |
|