incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [26/44] git commit: [#6534] ticket:441 Convert page names
Date Fri, 04 Oct 2013 14:43:14 GMT
[#6534] ticket:441 Convert page names


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/26fecece
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/26fecece
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/26fecece

Branch: refs/heads/master
Commit: 26fecece1e63c672cceca03530484b4fb9318f1c
Parents: 2b1f3c0
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Sep 20 12:45:06 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 4 14:21:22 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/tests/test_wiki.py | 6 ++++++
 ForgeImporters/forgeimporters/github/wiki.py            | 7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/26fecece/ForgeImporters/forgeimporters/github/tests/test_wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_wiki.py b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
index 01dec62..88e42d7 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -128,6 +128,12 @@ class TestGitHubWikiImporter(TestCase):
         assert_equal(upsert.call_args_list, [call('Home')])
         assert_equal(render.call_args_list, [call('Home.md', u'# test message')])
 
+    def test_convert_page_name(self):
+        f = GitHubWikiImporter()._convert_page_name
+        assert_equal(f('Page Name'), 'Page Name')
+        assert_equal(f('Page-Name'), 'Page Name')
+        assert_equal(f('Page / Name'), 'Page   Name')
+
     def test_convert_gollum_page_links(self):
         f = GitHubWikiImporter().convert_gollum_page_links
         assert_equal(f(u'[[Page]]'), u'[Page]')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/26fecece/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 11fb50b..bc82ac8 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -187,6 +187,7 @@ class GitHubWikiImporter(ToolImporter):
             log.info('Not a wiki page %s. Skipping.' % filename)
             return
         mod_date = datetime.utcfromtimestamp(commit.committed_date)
+        name = self._convert_page_name(name)
         wiki_page = WM.Page.upsert(name)
         if filename in commit.tree:
             wiki_page.text = self.convert_markup(h.really_unicode(text), filename)
@@ -199,6 +200,10 @@ class GitHubWikiImporter(ToolImporter):
         wiki_page.commit()
         return wiki_page
 
+    def _convert_page_name(self, name):
+        """Convert '-' and '/' into spaces in page name to match github behavior"""
+        return name.replace('-', ' ').replace('/', ' ')
+
     def import_pages(self, wiki_url, history=None):
         wiki_path = mkdtemp()
         wiki = git.Repo.clone_from(wiki_url, to_path=wiki_path, bare=True)
@@ -245,7 +250,7 @@ class GitHubWikiImporter(ToolImporter):
                              \]\])                    # tag end''', re.VERBOSE)
 
         def repl(match):
-            page = match.group('page').replace('-', ' ').replace('/', ' ')
+            page = self._convert_page_name(match.group('page'))
             title = match.groupdict().get('title')
             quote = match.groupdict().get('quote')
             if quote:


Mime
View raw message