113 lines
2.4 KiB
Ruby
113 lines
2.4 KiB
Ruby
require_relative "redmine-to-gitea"
|
|
require_relative 'textile-to-markdown'
|
|
|
|
Encoding.default_internal = Encoding::UTF_8
|
|
Encoding.default_external = Encoding::UTF_8
|
|
|
|
fake_user_names_proc = Proc.new { |x| "redmine_importer" }
|
|
user_names_proc = Proc.new { |x|
|
|
case x
|
|
when 488 then "abenmiloud"
|
|
when 40 then "benpro"
|
|
when 443 then "btatu"
|
|
when 406 then "emorino"
|
|
when 3 then "gcolpart"
|
|
when 408 then "jcougnoux"
|
|
when 400 then "jdubois"
|
|
when 391 then "jlecour"
|
|
when 430 then "lpoujol"
|
|
when 398 then "pdiogoantunes"
|
|
when 7 then "romain"
|
|
when 240 then "drustan"
|
|
when 344 then "vlaborie"
|
|
when 275 then "jmartinez"
|
|
when 284 then "agobin"
|
|
when 527 then "sbencherif"
|
|
else
|
|
"redmine_importer"
|
|
end
|
|
}
|
|
|
|
statuses_proc = Proc.new { |x|
|
|
case x
|
|
when 1 then "Nouveau"
|
|
when 2 then "En cours"
|
|
when 3 then "Résolu"
|
|
when 4 then "Commentaire"
|
|
when 5 then "Fermé"
|
|
when 6 then "Rejeté"
|
|
when 8 then "Répondu par le support"
|
|
when 11 then "Reporté"
|
|
else
|
|
"Unknown"
|
|
end
|
|
}
|
|
|
|
closed_statuses_proc = Proc.new { |x|
|
|
case x
|
|
when 1, 2, 4, 8 then false
|
|
when 3, 5, 6, 11 then true
|
|
else
|
|
false
|
|
end
|
|
}
|
|
|
|
priorities_proc = Proc.new { |x|
|
|
case x
|
|
when 3 then "Bas"
|
|
when 4 then "Normal"
|
|
when 5 then "Haut"
|
|
when 6 then "Urgent"
|
|
when 7 then "Immédiat"
|
|
else
|
|
"Unknown"
|
|
end
|
|
}
|
|
|
|
mapping = RedmineToGitea::Mapping.new(
|
|
user_names_proc: fake_user_names_proc,
|
|
statuses_proc: statuses_proc,
|
|
closed_statuses_proc: closed_statuses_proc,
|
|
priorities_proc: priorities_proc
|
|
)
|
|
settings = RedmineToGitea::Settings.new(
|
|
mapping: mapping,
|
|
date_format: "%Y-%m-%d %H:%M:%S",
|
|
textile_to_markdown: TextileToMarkdown,
|
|
)
|
|
migrator = RedmineToGitea::Migrator.new(
|
|
redmine_api: Redmine::API.new(
|
|
api_key: ENV.fetch('REDMINE_API_KEY'),
|
|
base_url: ENV.fetch('REDMINE_BASE_URL')
|
|
),
|
|
gitea_api: Gitea::API.new(
|
|
api_key: ENV.fetch('GITEA_API_KEY'),
|
|
base_url: ENV.fetch('GITEA_BASE_URL')
|
|
),
|
|
settings: settings
|
|
)
|
|
|
|
gitea_owner = "jlecour"
|
|
gitea_repo = "tests-redmine-to-gitea"
|
|
|
|
migrator.reset_project(
|
|
owner: gitea_owner,
|
|
repo_payload: {
|
|
"name": gitea_repo,
|
|
"private": true,
|
|
},
|
|
collaborators: [
|
|
"redmine_importer"
|
|
]
|
|
)
|
|
|
|
# evolix-private: 231
|
|
# ansible-roles: 226
|
|
# evogestion: 209
|
|
|
|
migrator.issues(
|
|
redmine_project: 209,
|
|
gitea_owner: gitea_owner,
|
|
gitea_repo: gitea_repo
|
|
)
|