incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [13/21] git commit: [#6622] ticket:435 convert user/project references into shortlinks
Date Wed, 13 Nov 2013 17:19:32 GMT
[#6622] ticket:435 convert user/project references into shortlinks

Because we don't know the proper mount point.


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

Branch: refs/heads/master
Commit: d2d337b0f74c9ace05f1c9dbbda2e2de52152f41
Parents: 3cda147
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Oct 14 17:20:59 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Nov 13 17:16:56 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/tests/test_utils.py   | 6 +++---
 ForgeImporters/forgeimporters/github/tests/test_wiki.py    | 2 +-
 ForgeImporters/forgeimporters/github/tracker.py            | 6 +-----
 ForgeImporters/forgeimporters/github/utils.py              | 9 +++------
 ForgeImporters/forgeimporters/github/wiki.py               | 6 +-----
 ForgeImporters/forgeimporters/tests/github/test_tracker.py | 8 ++++----
 6 files changed, 13 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d2d337b0/ForgeImporters/forgeimporters/github/tests/test_utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_utils.py b/ForgeImporters/forgeimporters/github/tests/test_utils.py
index e3ba75c..d60cb0d 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -6,7 +6,7 @@ from forgeimporters.github.utils import GitHubMarkdownConverter
 class TestGitHubMarkdownConverter(object):
 
     def setUp(self):
-        self.conv = GitHubMarkdownConverter('user', 'project', 'p', 'mount')
+        self.conv = GitHubMarkdownConverter('user', 'project')
 
     def test_convert_sha(self):
         text = '16c999e8c71134401a78d4d46435517b2271d6ac'
@@ -30,7 +30,7 @@ class TestGitHubMarkdownConverter(object):
     def test_convert_user_repo_sha(self):
         text = 'user/project@16c999e8c71134401a78d4d46435517b2271d6ac'
         result = self.conv.convert(text)
-        assert_equal(result, '[p:mount:16c999]')
+        assert_equal(result, '[16c999]')
 
         # Not a current project
         text = 'user/p@16c999e8c71134401a78d4d46435517b2271d6ac'
@@ -62,7 +62,7 @@ class TestGitHubMarkdownConverter(object):
     def test_convert_user_repo_ticket(self):
         text = 'user/project#1'
         result = self.conv.convert(text)
-        assert_equal(result, '[p:mount:#1]')
+        assert_equal(result, '[#1]')
 
         # Not a current project
         text = 'user/p#1'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d2d337b0/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 ea54b10..818f8ee 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -291,7 +291,7 @@ Our website is <http://sf.net>.
         importer.github_wiki_url = 'https://github.com/a/b/wiki'
         importer.app = Mock()
         importer.app.url = '/p/test/wiki/'
-        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'proj', 'p',
'mount')
+        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'proj')
         f = importer.convert_markup
         source = u'''Look at [[this page|Some Page]]
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d2d337b0/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index 6dfa507..c2141ce 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -112,11 +112,7 @@ class GitHubTrackerImporter(ToolImporter):
                 }
             )
         self.github_markdown_converter = GitHubMarkdownConverter(
-            kw['user_name'],
-            project_name,
-            project.shortname,
-            app.config.options.mount_point,
-        )
+            kw['user_name'], project_name)
         ThreadLocalORMSession.flush_all()
         extractor = GitHubProjectExtractor(project_name)
         try:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d2d337b0/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index f00140d..63a55e4 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -3,9 +3,8 @@ import re
 
 class GitHubMarkdownConverter(object):
 
-    def __init__(self, gh_user, gh_project, project, mount_point):
+    def __init__(self, gh_user, gh_project):
         self.gh_project = '%s/%s' % (gh_user, gh_project)
-        self.project = '%s:%s' % (project, mount_point)
         self.gh_base_url = u'https://github.com/'
 
     def convert(self, text):
@@ -57,8 +56,7 @@ class GitHubMarkdownConverter(object):
         project = '%s/%s' % (m.group(2), m.group(3))
         tid = m.group(4)
         if project == self.gh_project:
-            link = ':'.join([self.project, '#' + tid])
-            return '%s[%s]%s' % (m.group(1), link, m.group(5))
+            return '%s[%s]%s' % (m.group(1), '#' + tid, m.group(5))
         title = project + '#' + tid
         return ''.join([m.group(1),
                         self._gh_ticket_url(project, tid, title),
@@ -75,8 +73,7 @@ class GitHubMarkdownConverter(object):
         project = '%s/%s' % (m.group(2), m.group(3))
         sha = m.group(4)
         if project == self.gh_project:
-            link = ':'.join([self.project, sha[:6]])
-            return '%s[%s]%s' % (m.group(1), link, m.group(5))
+            return '%s[%s]%s' % (m.group(1), sha[:6], m.group(5))
         title = project + '@' + sha[:6]
         return ''.join([m.group(1),
                         self._gh_commit_url(project, sha, title),

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d2d337b0/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 1290224..8fae1b1 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -156,11 +156,7 @@ class GitHubWikiImporter(ToolImporter):
         with_history = tool_option == 'import_history'
         ThreadLocalORMSession.flush_all()
         self.github_markdown_converter = GitHubMarkdownConverter(
-            user_name,
-            project_name,
-            project.shortname,
-            self.app.config.options.mount_point,
-        )
+            user_name, project_name)
         try:
             M.session.artifact_orm_session._get().skip_mod_date = True
             with h.push_config(c, app=self.app):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d2d337b0/ForgeImporters/forgeimporters/tests/github/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/github/test_tracker.py b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
index 6b8c736..43a3bb6 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
@@ -79,7 +79,7 @@ class TestTrackerImporter(TestCase):
             'labels': [{'name': 'first'}, {'name': 'second'}],
         }
         importer = tracker.GitHubTrackerImporter()
-        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project', 'p',
'mount')
+        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project')
         with mock.patch.object(tracker, 'datetime') as dt:
             dt.strptime.side_effect = lambda s,f: s
             importer.process_fields(ticket, issue)
@@ -135,7 +135,7 @@ class TestTrackerImporter(TestCase):
                 }
             ]
         importer = tracker.GitHubTrackerImporter()
-        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project', 'p',
'mount')
+        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project')
         importer.process_comments(extractor, ticket, issue)
         self.assertEqual(ticket.discussion_thread.add_post.call_args_list[0], mock.call(
                 text='*Originally posted by:* [me](https://github.com/me)\nhello',
@@ -210,7 +210,7 @@ def hello(name):
             'labels': [{'name': 'first'}, {'name': 'second'}],
         }
         importer = tracker.GitHubTrackerImporter()
-        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project', 'p',
'mount')
+        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project')
         with mock.patch.object(tracker, 'datetime') as dt:
             dt.strptime.side_effect = lambda s,f: s
             importer.process_fields(ticket, issue)
@@ -241,7 +241,7 @@ def hello(name):
                 }
             ]
         importer = tracker.GitHubTrackerImporter()
-        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project', 'p',
'mount')
+        importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project')
         importer.process_comments(extractor, ticket, issue)
         self.assertEqual(ticket.discussion_thread.add_post.call_args_list[0], mock.call(
                 text=body_converted,


Mime
View raw message