sagemath / trac-to-github

Script to migrate Trac tickets to GitHub issues and the Trac wiki to markdown. Input: https://trac.sagemath.org/ ➠ Intermediate: https://github.com/sagemath/trac_to_gh ➠ Output: https://github.com/sagemath/sage/issues
https://trac.sagemath.org/ticket/30363
7 stars 5 forks source link

Script broken when [wiki] migrate: yes #168

Closed mkoeppe closed 1 year ago

mkoeppe commented 1 year ago
Traceback (most recent call last):
  File "/Users/mkoeppe/s/sage/trac-to-github/worktree-production/./migrate.py", line 2807, in <module>
    convert_issues(source, dest, only_issues = only_issues, blacklist_issues = blacklist_issues)
  File "/Users/mkoeppe/s/sage/trac-to-github/worktree-production/./migrate.py", line 2105, in convert_issues
    'description' : trac2markdown(milestone.pop('description'), '/milestones/', conv_help, False),
  File "/Users/mkoeppe/s/sage/trac-to-github/worktree-production/./migrate.py", line 946, in trac2markdown
    line = RE_HEADING2.sub(heading_replace, line)
  File "/Users/mkoeppe/s/sage/trac-to-github/worktree-production/./migrate.py", line 747, in heading_replace
    f.write(conv_help._trac_wiki_path + '#' + heading.replace(' ', '') + ' '
AttributeError: 'IssuesConversionHelper' object has no attribute '_trac_wiki_path'

@kwankyu

kwankyu commented 1 year ago

Does this occur when converting wiki together with issues?

I never tested with this option. Instead of trying to fix this, perhaps we may do the conversion in two steps: first issues and then wiki, thus avoiding the risk of unexpected complications for the current migration.

kwankyu commented 1 year ago

Anyway, I think I see where the bug is.

kwankyu commented 1 year ago

This might be the fix

diff --git a/migrate.py b/migrate.py
index d6172871ae..cdff51d92a 100755
--- a/migrate.py
+++ b/migrate.py
@@ -744,7 +744,7 @@ def trac2markdown(text, base_path, conv_help, multilines=default_multilines):
         level = len(match.group(1))
         heading = match.group(2).rstrip()

-        if create_wiki_link_conversion_table:
+        if not isinstance(conv_help, IssuesConversionHelper) and create_wiki_link_conversion_table:
             with open('wiki_path_conversion_table.txt', "a") as f:
                 f.write(conv_help._trac_wiki_path + '#' + heading.replace(' ', '') + ' '
                         + conv_help._wiki_path + '#' + heading.replace(' ', '-'))