From 3a97f931cebc9ee449690075b5eea6d9c648c885 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 18 Sep 2022 13:48:27 -0700 Subject: [PATCH 1/5] migrate.cfg.example: Fix typo, remove duplicate item --- migrate.cfg.example | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/migrate.cfg.example b/migrate.cfg.example index 3058bf2e79..fef955215f 100644 --- a/migrate.cfg.example +++ b/migrate.cfg.example @@ -12,7 +12,7 @@ url: https://example.com/xmlrpc # optional path to trac instance used to convert some attachments path: /path/to/trac/instance -# mapping file from git hashes to subversion revisions and branche names ("hash revision @branch" in each line) +# mapping file from git hashes to subversion revisions and branch names ("hash revision @branch" in each line) svngitmap: /path/to/git_svn.map @@ -24,9 +24,6 @@ usernames = { 'trac2': 'git2' } -# project's path -project_name: foo/bar - # URL of the GitHub web API (default: https://api.github.com) # url: https://api.github.com From de8c8bdbf01a80a6e8da7c7c058ac6a70808ae91 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 18 Sep 2022 13:48:49 -0700 Subject: [PATCH 2/5] requirements.txt: New --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..99e642763f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pygithub +requests From d3b2056341d50a8491c9188632111356b332f1e2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 18 Sep 2022 14:06:16 -0700 Subject: [PATCH 3/5] Add requirements.txt --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b81ba43880..ec31f16961 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Migrating a Trac project to GitHub is a relatively complex process involving fou * Migrate issues and milestones * Migrate wiki pages -This script takes care of the third bullet point. +This script takes care of the third and fourth bullet points. Usage: @@ -53,5 +53,6 @@ LGPL license version 3.0. Requirements ============== - * Python 2 with xmlrpclib, requests, [PyGithub](https://github.com/PyGithub/PyGithub) + * Python 2 with xmlrpclib or Python 3; requests, [PyGithub](https://github.com/PyGithub/PyGithub), + see ```requirements.txt``` * Trac with [XML-RPC plugin](http://trac-hacks.org/wiki/XmlRpcPlugin) enabled From 148f87258155b702f0bbef6abad85680188f2386 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 18 Sep 2022 14:08:02 -0700 Subject: [PATCH 4/5] Handle wiki pages with slashes in the title --- migrate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/migrate.py b/migrate.py index 141a64a66b..0c4ff3aec4 100755 --- a/migrate.py +++ b/migrate.py @@ -763,13 +763,16 @@ def convert_wiki(source, dest): converted += ' * [' + name + '](' + url + ')\n' # TODO we could use the GitHub API to write into the Wiki repository of the GitHub project + outfile = os.path.join(wiki_export_dir, pagename + '.md') + # For wiki page names with slashes + os.makedirs(os.path.dirname(outfile), exist_ok=True) try : - open(os.path.join(wiki_export_dir, pagename + '.md'), 'w').write(converted) + open(outfile, 'w').write(converted) except UnicodeEncodeError as e : print ('EXCEPTION:', e) print (' Context:', e.object[e.start-20:e.end+20]) print (' Retrying with UTF-8 encoding') - codecs.open(os.path.join(wiki_export_dir, pagename + '.md'), 'w', 'utf-8').write(converted) + codecs.open(outfile, 'w', 'utf-8').write(converted) if __name__ == "__main__": From 1a50daaee6d16e02b232f13d14632add44a91d2c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 18 Sep 2022 14:09:07 -0700 Subject: [PATCH 5/5] Only require github info when must_convert_issues --- migrate.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/migrate.py b/migrate.py index 0c4ff3aec4..49d213de65 100755 --- a/migrate.py +++ b/migrate.py @@ -779,12 +779,15 @@ def convert_wiki(source, dest): source = client.ServerProxy(trac_url) dest = None - if github_token is not None : - github = Github(github_token, base_url=github_api_url) - else : - github = Github(github_username, github_password, base_url=github_api_url) - dest = github.get_repo(github_project) - gh_user = github.get_user() + gh_user = None + + if must_convert_issues: + if github_token is not None : + github = Github(github_token, base_url=github_api_url) + else : + github = Github(github_username, github_password, base_url=github_api_url) + dest = github.get_repo(github_project) + gh_user = github.get_user() if dest is not None : for l in dest.get_labels() :