You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/11/13 23:57:21 UTC
[01/44] git commit: [#6859] Prevent escaping of cached html
Updated Branches:
refs/heads/cj/6815 1da006b1c -> cce5b5cd3 (forced update)
[#6859] Prevent escaping of cached html
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f09d0b64
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f09d0b64
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f09d0b64
Branch: refs/heads/cj/6815
Commit: f09d0b6491841ed283d840ad986bf69f4a86eab5
Parents: 9f8ff48
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Fri Nov 8 16:46:10 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Nov 8 16:46:10 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 2 +-
Allura/allura/tests/test_globals.py | 2 ++
ForgeWiki/forgewiki/tests/functional/test_root.py | 14 ++++++++++++++
3 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f09d0b64/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 7771753..6ded51a 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -105,7 +105,7 @@ class ForgeMarkdown(markdown.Markdown):
if cache.md5 is not None:
md5 = hashlib.md5(source_text.encode('utf-8')).hexdigest()
if cache.md5 == md5:
- return cache.html
+ return h.html.literal(cache.html)
start = time.time()
html = self.convert(source_text)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f09d0b64/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 32cdffd..c35f69c 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -593,10 +593,12 @@ class TestCachedMarkdown(unittest.TestCase):
@patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='0')
def test_valid_cache(self):
+ from jinja2 import Markup
self.md.cached_convert(self.post, 'text')
with patch.object(self.md, 'convert') as convert_func:
html = self.md.cached_convert(self.post, 'text')
self.assertEqual(html, self.expected_html)
+ self.assertIsInstance(html, Markup)
self.assertFalse(convert_func.called)
self.post.text = u"text [[macro]] pass"
html = self.md.cached_convert(self.post, 'text')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f09d0b64/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index a55176f..8be7ff8 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -578,6 +578,20 @@ class TestRootController(TestController):
req.forms[1].submit()
assert 'The resource was found at http://localhost/p/test/wiki/new_title/;' in self.app.get('/p/test/wiki/')
+ @patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='0')
+ def test_cached_html(self):
+ """Ensure cached html is not escaped."""
+ html = '<p><span>My Html</span></p>'
+ self.app.post('/wiki/cache/update', params={
+ 'title': 'cache',
+ 'text': html,
+ 'labels': '',
+ 'viewable_by-0.id': 'all'})
+ # first request caches html, second serves from cache
+ r = self.app.get('/wiki/cache/')
+ r = self.app.get('/wiki/cache/')
+ assert_true(html in r)
+
def test_page_delete(self):
self.app.post('/wiki/aaa/update', params={
'title':'aaa',
[02/44] git commit: [#6694] push To: header selection up into
sendsimplemail
Posted by jo...@apache.org.
[#6694] push To: header selection up into sendsimplemail
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/35eeee58
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/35eeee58
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/35eeee58
Branch: refs/heads/cj/6815
Commit: 35eeee58a77133f49d0170bd4ec7dcd92216a16d
Parents: f09d0b6
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Nov 8 20:08:05 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Nov 8 20:08:05 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/mail_util.py | 15 +++++++--------
Allura/allura/tasks/mail_tasks.py | 2 +-
Allura/allura/tests/test_tasks.py | 6 ++++--
3 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/35eeee58/Allura/allura/lib/mail_util.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/mail_util.py b/Allura/allura/lib/mail_util.py
index e6b2b31..ef0cc71 100644
--- a/Allura/allura/lib/mail_util.py
+++ b/Allura/allura/lib/mail_util.py
@@ -202,16 +202,15 @@ class SMTPClient(object):
self._client = None
def sendmail(self, addrs, fromaddr, reply_to, subject, message_id, in_reply_to, message,
- sender=None, references=None, cc=None):
- if not addrs: return
- # We send one message with multiple envelope recipients, so use a generic To: addr
- # It might be nice to refactor to send one message per recipient, and use the actual To: addr
- if len(addrs) == 1:
- message['To'] = AddrHeader(h.really_unicode(addrs[0]))
+ sender=None, references=None, cc=None, to=None):
+ if not addrs:
+ return
+ if to:
+ message['To'] = AddrHeader(h.really_unicode(to))
else:
- message['To'] = Header(reply_to)
+ message['To'] = AddrHeader(reply_to)
message['From'] = AddrHeader(fromaddr)
- message['Reply-To'] = Header(reply_to)
+ message['Reply-To'] = AddrHeader(reply_to)
message['Subject'] = Header(subject)
message['Message-ID'] = Header('<' + message_id + u'>')
if sender:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/35eeee58/Allura/allura/tasks/mail_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index 8151d34..0b87024 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -167,4 +167,4 @@ def sendsimplemail(
multi_msg = mail_util.make_multipart_message(plain_msg, html_msg)
smtp_client.sendmail(
[toaddr], fromaddr, reply_to, subject, message_id,
- in_reply_to, multi_msg, sender=sender, references=references, cc=cc)
+ in_reply_to, multi_msg, sender=sender, references=references, cc=cc, to=toaddr)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/35eeee58/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 9015f66..23aab99 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -278,7 +278,7 @@ class TestMailTasks(unittest.TestCase):
body = body.split('\n')
assert_in('From: noreply@in.sf.net', body)
- def test_email_sender_header(self):
+ def test_email_sender_to_headers(self):
c.user = M.User.by_username('test-admin')
with mock.patch.object(mail_tasks.smtp_client, '_client') as _client:
mail_tasks.sendsimplemail(
@@ -294,13 +294,14 @@ class TestMailTasks(unittest.TestCase):
body = body.split('\n')
assert_in('From: "Test Admin" <te...@users.localhost>', body)
assert_in('Sender: tickets@test.p.sf.net', body)
+ assert_in('To: test@mail.com', body)
_client.reset_mock()
mail_tasks.sendmail(
fromaddr=str(c.user._id),
destinations=[ str(c.user._id) ],
text=u'This is a test',
- reply_to=u'noreply@sf.net',
+ reply_to=u'123@tickets.test.p.sf.net',
subject=u'Test subject',
sender=u'tickets@test.p.sf.net',
message_id=h.gen_message_id())
@@ -309,6 +310,7 @@ class TestMailTasks(unittest.TestCase):
body = body.split('\n')
assert_in('From: "Test Admin" <te...@users.localhost>', body)
assert_in('Sender: tickets@test.p.sf.net', body)
+ assert_in('To: 123@tickets.test.p.sf.net', body)
def test_email_references_header(self):
c.user = M.User.by_username('test-admin')
[43/44] git commit: [#6815] Include assigned_to field in Allura
tracker import
Posted by jo...@apache.org.
[#6815] Include assigned_to field in Allura tracker import
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c330602a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c330602a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c330602a
Branch: refs/heads/cj/6815
Commit: c330602a4b50eeb60bd6800644b822ef62321be6
Parents: c1fc714
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Nov 8 18:37:58 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 22:48:49 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/forge/tracker.py | 18 ++++++++---
.../forgeimporters/tests/forge/test_tracker.py | 34 ++++++++++++++------
2 files changed, 38 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c330602a/ForgeImporters/forgeimporters/forge/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/forge/tracker.py b/ForgeImporters/forgeimporters/forge/tracker.py
index a9a17bb..c758651 100644
--- a/ForgeImporters/forgeimporters/forge/tracker.py
+++ b/ForgeImporters/forgeimporters/forge/tracker.py
@@ -127,12 +127,17 @@ class ForgeTrackerImporter(ToolImporter):
M.session.artifact_orm_session._get().skip_mod_date = True
for ticket_json in tracker_json['tickets']:
reporter = self.get_user(ticket_json['reported_by'])
+ owner = self.get_user(ticket_json['assigned_to'])
with h.push_config(c, user=reporter, app=app):
self.max_ticket_num = max(ticket_json['ticket_num'], self.max_ticket_num)
ticket = TM.Ticket(
app_config_id=app.config._id,
import_id=import_id_converter.expand(ticket_json['ticket_num'], app),
- description=self.annotate(ticket_json['description'], reporter, ticket_json['reported_by']),
+ description=self.annotate(
+ self.annotate(
+ ticket_json['description'],
+ owner, ticket_json['assigned_to'], label=' owned'),
+ reporter, ticket_json['reported_by'], label=' created'),
created_date=dateutil.parser.parse(ticket_json['created_date']),
mod_date=dateutil.parser.parse(ticket_json['mod_date']),
ticket_num=ticket_json['ticket_num'],
@@ -142,7 +147,8 @@ class ForgeTrackerImporter(ToolImporter):
labels=ticket_json['labels'],
votes_down=ticket_json['votes_down'],
votes_up=ticket_json['votes_up'],
- votes = ticket_json['votes_up'] - ticket_json['votes_down'],
+ votes=ticket_json['votes_up'] - ticket_json['votes_down'],
+ assigned_to_id=owner._id,
)
ticket.private = ticket_json['private'] # trigger the private property
self.process_comments(ticket, ticket_json['discussion_thread']['posts'])
@@ -170,14 +176,16 @@ class ForgeTrackerImporter(ToolImporter):
M.session.artifact_orm_session._get().skip_mod_date = False
def get_user(self, username):
+ if username is None:
+ return M.User.anonymous()
user = M.User.by_username(username)
if not user:
user = M.User.anonymous()
return user
- def annotate(self, text, user, username):
- if user._id is None:
- return '*Originally by:* %s\n\n%s' % (username, text)
+ def annotate(self, text, user, username, label=''):
+ if username and user.is_anonymous():
+ return '*Originally%s by:* %s\n\n%s' % (label, username, text)
return text
def process_comments(self, ticket, comments):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c330602a/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/forge/test_tracker.py b/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
index 321643e..0b8fa05 100644
--- a/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
@@ -53,6 +53,7 @@ class TestTrackerImporter(TestCase):
'tickets': [
{
'reported_by': 'rb1',
+ 'assigned_to': 'at1',
'ticket_num': 1,
'description': 'd1',
'created_date': '2013-09-01',
@@ -68,6 +69,7 @@ class TestTrackerImporter(TestCase):
},
{
'reported_by': 'rb2',
+ 'assigned_to': 'at2',
'ticket_num': 100,
'description': 'd2',
'created_date': '2013-09-03',
@@ -83,9 +85,14 @@ class TestTrackerImporter(TestCase):
},
],
})
- reporter = mock.Mock()
- importer.get_user = mock.Mock(return_value=reporter)
- importer.annotate = mock.Mock(side_effect=['ad1', 'ad2'])
+ anonymous = mock.Mock(_id=None, is_anonymous=lambda:True)
+ reporter = mock.Mock(is_anonymous=lambda:False)
+ author = mock.Mock(is_anonymous=lambda:False)
+ importer.get_user = mock.Mock(side_effect=[
+ reporter, author,
+ anonymous, anonymous,
+ ])
+ importer.annotate = mock.Mock(side_effect=['ad1', 'aad1', 'ad2', 'aad2'])
importer.process_comments = mock.Mock()
importer.process_bins = mock.Mock()
project, user = mock.Mock(), mock.Mock()
@@ -112,8 +119,10 @@ class TestTrackerImporter(TestCase):
foo='bar',
)
self.assertEqual(importer.annotate.call_args_list, [
- mock.call('d1', reporter, 'rb1'),
- mock.call('d2', reporter, 'rb2'),
+ mock.call('d1', author, 'at1', label=' owned'),
+ mock.call('ad1', reporter, 'rb1', label=' created'),
+ mock.call('d2', anonymous, 'at2', label=' owned'),
+ mock.call('ad2', anonymous, 'rb2', label=' created'),
])
self.assertEqual(TM.Ticket.call_args_list, [
mock.call(
@@ -123,7 +132,7 @@ class TestTrackerImporter(TestCase):
'app_config_id': 'orig_id',
'source_id': 1,
},
- description='ad1',
+ description='aad1',
created_date=datetime(2013, 9, 1),
mod_date=datetime(2013, 9, 2),
ticket_num=1,
@@ -134,6 +143,7 @@ class TestTrackerImporter(TestCase):
votes_down=1,
votes_up=2,
votes=1,
+ assigned_to_id=author._id,
),
mock.call(
app_config_id=app.config._id,
@@ -142,7 +152,7 @@ class TestTrackerImporter(TestCase):
'app_config_id': 'orig_id',
'source_id': 100,
},
- description='ad2',
+ description='aad2',
created_date=datetime(2013, 9, 3),
mod_date=datetime(2013, 9, 4),
ticket_num=100,
@@ -153,6 +163,7 @@ class TestTrackerImporter(TestCase):
votes_down=3,
votes_up=5,
votes=2,
+ assigned_to_id=None,
),
])
self.assertEqual(tickets[0].private, False)
@@ -211,16 +222,21 @@ class TestTrackerImporter(TestCase):
self.assertEqual(importer.get_user('foo'), 'bar')
self.assertEqual(M.User.anonymous.call_count, 0)
+ self.assertEqual(importer.get_user(None), 'anon')
+ self.assertEqual(M.User.anonymous.call_count, 1)
+
M.User.by_username.return_value = None
self.assertEqual(importer.get_user('foo'), 'anon')
- self.assertEqual(M.User.anonymous.call_count, 1)
+ self.assertEqual(M.User.anonymous.call_count, 2)
def test_annotate(self):
importer = tracker.ForgeTrackerImporter()
user = mock.Mock(_id=1)
+ user.is_anonymous.return_value = False
self.assertEqual(importer.annotate('foo', user, 'bar'), 'foo')
- user._id = None
+ user.is_anonymous.return_value = True
self.assertEqual(importer.annotate('foo', user, 'bar'), '*Originally by:* bar\n\nfoo')
+ self.assertEqual(importer.annotate('foo', user, None), 'foo')
@mock.patch.object(tracker, 'File')
@mock.patch.object(tracker, 'c')
[15/44] git commit: [#6622] ticket:435 Convert markdown in tracker
Posted by jo...@apache.org.
[#6622] ticket:435 Convert markdown in tracker
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/3cda147e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3cda147e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3cda147e
Branch: refs/heads/cj/6815
Commit: 3cda147e048ce9519e3fba62e945242b79ec462f
Parents: 23db53a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 17:03:07 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:56 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/tracker.py | 10 ++++++++--
.../forgeimporters/tests/github/test_tracker.py | 6 +++++-
2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3cda147e/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index c3c7ab4..6dfa507 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -111,6 +111,12 @@ class GitHubTrackerImporter(ToolImporter):
'project_name': project_name,
}
)
+ self.github_markdown_converter = GitHubMarkdownConverter(
+ kw['user_name'],
+ project_name,
+ project.shortname,
+ app.config.options.mount_point,
+ )
ThreadLocalORMSession.flush_all()
extractor = GitHubProjectExtractor(project_name)
try:
@@ -170,7 +176,7 @@ class GitHubTrackerImporter(ToolImporter):
u'{body}').format(
creator=self.get_user_link(issue['user']['login']),
owner=owner_line,
- body=GitHubMarkdownConverter().convert(body),
+ body=self.github_markdown_converter.convert(body),
)
ticket.labels = [label['name'] for label in issue['labels']]
@@ -182,7 +188,7 @@ class GitHubTrackerImporter(ToolImporter):
self.get_user_link(comment['user']['login']))
body = posted_by + body
p = ticket.discussion_thread.add_post(
- text = GitHubMarkdownConverter().convert(body),
+ text = self.github_markdown_converter.convert(body),
ignore_security = True,
timestamp = self.parse_datetime(comment['created_at']),
)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3cda147e/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 7cd3c90..6b8c736 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
@@ -16,11 +16,11 @@
# under the License.
from datetime import datetime
-from operator import itemgetter
from unittest import TestCase
import mock
from ...github import tracker
+from forgeimporters.github.utils import GitHubMarkdownConverter
class TestTrackerImporter(TestCase):
@@ -79,6 +79,7 @@ class TestTrackerImporter(TestCase):
'labels': [{'name': 'first'}, {'name': 'second'}],
}
importer = tracker.GitHubTrackerImporter()
+ importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project', 'p', 'mount')
with mock.patch.object(tracker, 'datetime') as dt:
dt.strptime.side_effect = lambda s,f: s
importer.process_fields(ticket, issue)
@@ -134,6 +135,7 @@ class TestTrackerImporter(TestCase):
}
]
importer = tracker.GitHubTrackerImporter()
+ importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project', 'p', 'mount')
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',
@@ -208,6 +210,7 @@ def hello(name):
'labels': [{'name': 'first'}, {'name': 'second'}],
}
importer = tracker.GitHubTrackerImporter()
+ importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project', 'p', 'mount')
with mock.patch.object(tracker, 'datetime') as dt:
dt.strptime.side_effect = lambda s,f: s
importer.process_fields(ticket, issue)
@@ -238,6 +241,7 @@ def hello(name):
}
]
importer = tracker.GitHubTrackerImporter()
+ importer.github_markdown_converter = GitHubMarkdownConverter('user', 'project', 'p', 'mount')
importer.process_comments(extractor, ticket, issue)
self.assertEqual(ticket.discussion_thread.add_post.call_args_list[0], mock.call(
text=body_converted,
[24/44] git commit: [#6622] ticket:469 A little refactoring and
regexes fix
Posted by jo...@apache.org.
[#6622] ticket:469 A little refactoring and regexes fix
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/05de134f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/05de134f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/05de134f
Branch: refs/heads/cj/6815
Commit: 05de134fbe059dd5b8b6c17d04dee9127ab52aaf
Parents: 11e2621
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Nov 11 13:07:47 2013 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:57 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 12 +++++-----
ForgeImporters/forgeimporters/github/utils.py | 23 +++++++++-----------
2 files changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/05de134f/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 f426d6b..f31bba8 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -42,12 +42,7 @@ class TestGitHubMarkdownConverter(object):
text = 'Ticket #1'
result = self.conv.convert(text)
assert_equal(result, 'Ticket [#1]')
-
- # github treats '#' in the begining as a header
- text = '#1'
- assert_equal(self.conv.convert(text), '#1')
- text = ' #1'
- assert_equal(self.conv.convert(text), ' #1')
+ assert_equal(self.conv.convert('#1'), '[#1]')
def test_convert_user_ticket(self):
text = 'user#1'
@@ -73,6 +68,11 @@ class TestGitHubMarkdownConverter(object):
text = '~~mistake~~'
assert_equal(self.conv.convert(text), '<s>mistake</s>')
+ def test_inline_code_block(self):
+ text = u'This `~~some text~~` converts to this ~~strike out~~.'
+ result = u'This `~~some text~~` converts to this <s>strike out</s>.'
+ assert_equal(self.conv.convert(text).strip(), result)
+
def test_convert_code_blocks(self):
text = u'''```python
print "Hello!"
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/05de134f/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index d509aa7..cfc3a59 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -18,9 +18,9 @@ class GitHubMarkdownConverter(object):
for line in lines:
nextline = False
for p in self.code_patterns:
- if line.lstrip().startswith(p):
+ if line.startswith(p):
if p == '```':
- syntax = line.lstrip().lstrip('`').strip()
+ syntax = line.lstrip('`').strip()
if syntax:
new_lines.append(self._codeblock_syntax(syntax))
in_block = not in_block
@@ -31,22 +31,19 @@ class GitHubMarkdownConverter(object):
if in_block:
new_lines.append(self._handle_code(line))
+ elif line.startswith(' '):
+ # indentation syntax code block - leave as is
+ new_lines.append(line)
else:
- _re = re.compile(r'`\s*(.*?)`')
+ _re = re.compile(r'`.*?`')
inline_matches = _re.findall(line)
-
- if line.startswith(' '):
- # code block due to github syntax
- new_lines.append(line)
- elif inline_matches and not inline_matches[0].isspace():
+ if inline_matches:
# need to not handle inline blocks as a text
for i, m in enumerate(inline_matches):
- line = line.replace('`%s`' % m, '<inline_block>%s</inline_block>' % i)
-
+ line = line.replace(m, '<inline_block>%s</inline_block>' % i)
line = self._handle_non_code(line)
for i, m in enumerate(inline_matches):
- line = line.replace('<inline_block>%s</inline_block>' % i, inline_matches[i])
-
+ line = line.replace('<inline_block>%s</inline_block>' % i, m)
new_lines.append(line)
else:
new_lines.append(self._handle_non_code(line))
@@ -71,7 +68,7 @@ class GitHubMarkdownConverter(object):
_re = re.compile(r'(\b)(\S+)#(\d+)(\b)')
text = _re.sub(self._convert_user_ticket, text)
- _re = re.compile(r'(\S+\s+)(#\d+)')
+ _re = re.compile(r'(\s|^)(#\d+)')
text = _re.sub(self._convert_ticket, text)
_re = re.compile(r'(\b)(\S+)/(\S+)@([0-9a-f]{40})(\b)')
[27/44] git commit: [#6865] sort categories on template and as added
by JS
Posted by jo...@apache.org.
[#6865] sort categories on template and as added by JS
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1989f48e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1989f48e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1989f48e
Branch: refs/heads/cj/6815
Commit: 1989f48e2aa05b117b42c414a13fecc97df991b3
Parents: 0ec51d7
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Nov 11 19:54:36 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 19:13:38 2013 +0000
----------------------------------------------------------------------
.../allura/ext/admin/templates/project_trove.html | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1989f48e/Allura/allura/ext/admin/templates/project_trove.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_trove.html b/Allura/allura/ext/admin/templates/project_trove.html
index bcd557d..fb799da 100644
--- a/Allura/allura/ext/admin/templates/project_trove.html
+++ b/Allura/allura/ext/admin/templates/project_trove.html
@@ -25,7 +25,7 @@
{% macro show_trove_base_cat(base) %}
<h3>{{base.fullname}}</h3>
<div id="trove_existing_{{base.shortname}}" class="trove_existing grid-19">
- {% for cat in c.project.troves_by_type(base.shortname) %}
+ {% for cat in c.project.troves_by_type(base.shortname)|sort(attribute='fullpath') %}
<div style="clear: both">
<span class="trove_fullpath">{{cat.fullpath}}</span>
<form id="delete_trove_{{base.shortname}}_{{cat.trove_cat_id}}"
@@ -97,8 +97,20 @@
});
}
else{
- $('#trove_existing_'+type).find('span.empty_msg').remove();
- $('#trove_existing_'+type).prepend('<div><span class="trove_fullpath">'+resp.trove_full_path+'</span> <form class="trove_deleter"><input type="hidden" name="type" value="'+type+'"><input type="hidden" name="trove" value="'+new_id+'">'+del_btn+'</form></div>');
+ var $existing = $('#trove_existing_'+type);
+ $existing.find('span.empty_msg').remove();
+ var insertAfter = null;
+ $existing.children().each(function() {
+ if($('.trove_fullpath', this).text() < resp.trove_full_path) {
+ insertAfter = this;
+ }
+ });
+ var $newItem = $('<div><span class="trove_fullpath">'+resp.trove_full_path+'</span> <form class="trove_deleter"><input type="hidden" name="type" value="'+type+'"><input type="hidden" name="trove" value="'+new_id+'">'+del_btn+'</form></div>');
+ if (insertAfter) {
+ $newItem.insertAfter(insertAfter);
+ } else {
+ $newItem.prependTo($existing);
+ }
}
});
});
[05/44] git commit: [#6622] ticket:435 convert github markup
Posted by jo...@apache.org.
[#6622] ticket:435 convert github markup
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/18b4e34e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/18b4e34e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/18b4e34e
Branch: refs/heads/cj/6815
Commit: 18b4e34e9e5893ed7b92719442bc143faf7f49ce
Parents: a4e46b7
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Thu Oct 10 12:10:34 2013 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:54 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_wiki.py | 36 ++++++++++++++++++++
ForgeImporters/forgeimporters/github/wiki.py | 4 ++-
2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/18b4e34e/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 50c905d..bb2a383 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -479,6 +479,42 @@ some text and **[Tips n' Tricks]**
result = u'<p><strong>[[this checklist|Troubleshooting]]</strong></p>'
assert_equal(f(source, 't.textile').strip(), result)
+ def test_convert_sha_github_markup(self):
+ html = 'SHA: 16c999e8c71134401a78d4d46435517b2271d6ac'
+ importer = GitHubWikiImporter()
+ result = importer.convert_github_markup(html)
+ assert_equal(result, 'SHA: [16c999]')
+
+ def test_convert_user_sha_github_markup(self):
+ html = 'User@SHA: mojombo@16c999e8c71134401a78d4d46435517b2271d6ac'
+ importer = GitHubWikiImporter()
+ result = importer.convert_github_markup(html)
+ assert_equal(result, 'User@SHA:[16c999]')
+
+ def test_convert_user_repo_sha_github_markup(self):
+ html = 'User/Repository@SHA: mojombo/github-flavored-markdown@16c999e8c71134401a78d4d46435517b2271d6ac'
+ importer = GitHubWikiImporter()
+ result = importer.convert_github_markup(html)
+ assert_equal(result, 'User/Repository@SHA: [16c999]')
+
+ def test_convert_ticket_github_markup(self):
+ html = 'Ticket: #1'
+ importer = GitHubWikiImporter()
+ result = importer.convert_github_markup(html)
+ assert_equal(result, 'Ticket: [#1]')
+
+ def test_convert_username_ticket_github_markup(self):
+ html = 'User#Num: user#1'
+ importer = GitHubWikiImporter()
+ result = importer.convert_github_markup(html)
+ assert_equal(result, 'User#Num: [#1]')
+
+ def test_convert_username_repo_ticket_github_markup(self):
+ html = 'User/Repository#Num: user/repo#1'
+ importer = GitHubWikiImporter()
+ result = importer.convert_github_markup(html)
+ assert_equal(result, 'User/Repository#Num: [#1]')
+
class TestGitHubWikiImportController(TestController, TestCase):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/18b4e34e/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index fff43ad..f95ba44 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -264,7 +264,7 @@ class GitHubWikiImporter(ToolImporter):
"""
name, ext = os.path.splitext(filename)
if ext in self.markdown_exts:
- return text
+ return self.convert_github_markup(text)
try:
import html2text
@@ -394,6 +394,7 @@ class GitHubWikiImporter(ToolImporter):
a.setString(new_prefix + new_page)
return unicode(soup)
+
def _prepare_textile_text(self, text):
# need to convert lists properly
text_lines = text.splitlines()
@@ -406,3 +407,4 @@ class GitHubWikiImporter(ToolImporter):
# so these tags will not be affected by converter
text = text.replace('[[', '<notextile>[[').replace(']]', ']]</notextile>')
return text
+
[22/44] git commit: [#6622] ticket:469 improved regex
Posted by jo...@apache.org.
[#6622] ticket:469 improved regex
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/bf301e00
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/bf301e00
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/bf301e00
Branch: refs/heads/cj/6815
Commit: bf301e006358e0a4d65d720caee8b8f20b097d5f
Parents: 43f1692
Author: coldmind <so...@yandex.ru>
Authored: Wed Nov 6 20:19:06 2013 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:57 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/utils.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bf301e00/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index 292b41e..17e28ac 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -68,22 +68,22 @@ class GitHubMarkdownConverter(object):
output. ``text`` is *not* code.
"""
- _re = re.compile(r'(\s|^)(\S+)/(\S+)#(\d+)(\s|$)')
+ _re = re.compile(r'(\b)(\S+)/(\S+)#(\d+)(\b)')
text = _re.sub(self._convert_user_repo_ticket, text)
- _re = re.compile(r'(\s|^)(\S+)#(\d+)(\s|$)')
+ _re = re.compile(r'(\b)(\S+)#(\d+)(\b)')
text = _re.sub(self._convert_user_ticket, text)
_re = re.compile(r'(\S+\s+)(#\d+)')
text = _re.sub(self._convert_ticket, text)
- _re = re.compile(r'(\s|^)(\S+)/(\S+)@([0-9a-f]{40})(\s|$)')
+ _re = re.compile(r'(\b)(\S+)/(\S+)@([0-9a-f]{40})(\b)')
text = _re.sub(self._convert_user_repo_sha, text)
- _re = re.compile(r'(\s|^)(\S+)@([0-9a-f]{40})(\s|$)')
+ _re = re.compile(r'(\b)(\S+)@([0-9a-f]{40})(\b)')
text = _re.sub(self._convert_user_sha, text)
- _re = re.compile(r'(\s|^)([0-9a-f]{40})(\s|$)')
+ _re = re.compile(r'(\b)([0-9a-f]{40})(\b)')
text = _re.sub(self._convert_sha, text)
_re = re.compile(r'~~(.*)~~',)
[18/44] git commit: [#6622] ticket:469 handling github inline code
Posted by jo...@apache.org.
[#6622] ticket:469 handling github inline code
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/43f16922
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/43f16922
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/43f16922
Branch: refs/heads/cj/6815
Commit: 43f16922c239d5445e455986771783d0e536ffcb
Parents: f9db5f9
Author: coldmind <so...@yandex.ru>
Authored: Wed Nov 6 19:35:57 2013 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:56 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/utils.py | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/43f16922/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index 03dfe1b..292b41e 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -33,8 +33,14 @@ class GitHubMarkdownConverter(object):
if in_block:
new_lines.append(self._handle_code(line))
else:
+ _re = re.compile(r'`\s*(.*?)`')
+ is_inline_code = _re.findall(line)
+
if line.lstrip().startswith(' '):
- new_lines.append(self._handle_code(line))
+ # code block due to github syntax
+ continue
+ elif is_inline_code and not is_inline_code[0].isspace():
+ new_lines.append(self._handle_inline_code(line))
else:
new_lines.append(self._handle_non_code(line))
return new_lines
@@ -47,6 +53,16 @@ class GitHubMarkdownConverter(object):
text = ' ' + text
return text
+ def _handle_inline_code(self, text):
+ """Return a string that will replace ``text`` in the final text
+ output. ``text`` is inline code.
+
+ """
+ _re = re.compile(r'`(\s*)(.*?)`')
+ text = _re.sub(self._convert_inline_codeblock, text)
+
+ return text
+
def _handle_non_code(self, text):
"""Return a string that will replace ``text`` in the final text
output. ``text`` is *not* code.
@@ -125,4 +141,8 @@ class GitHubMarkdownConverter(object):
return '<s>%s</s>' % m.group(1)
def _codeblock_syntax(self, text):
- return '\n :::%s' % text
\ No newline at end of file
+ return '\n :::%s' % text
+
+ def _convert_inline_codeblock(self, m):
+ text = m.group(0)
+ return '**%s**' % text
[31/44] git commit: [#6866] [#6479] proper social network URL check;
allow clearing out FB url
Posted by jo...@apache.org.
[#6866] [#6479] proper social network URL check; allow clearing out FB url
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/ff04c8b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ff04c8b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ff04c8b2
Branch: refs/heads/cj/6815
Commit: ff04c8b209e65ef7cfdc91b7941eee2e7e5ce859
Parents: d1aa716
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Nov 11 20:33:52 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 19:19:08 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 9 +++++----
Allura/allura/tests/unit/test_project.py | 8 ++++++++
2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ff04c8b2/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index e1b0229..4643be6 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -390,13 +390,14 @@ class ProjectAdminController(BaseController):
h.log_action(log, 'change project support page').info('')
M.AuditLog.log('change project support page to %s', support_page)
c.project.support_page = support_page
- if twitter_handle != c.project.social_account('Twitter'):
+ old_twitter = c.project.social_account('Twitter')
+ if not old_twitter or twitter_handle != old_twitter.accounturl:
h.log_action(log, 'change project twitter handle').info('')
M.AuditLog.log('change project twitter handle to %s', twitter_handle)
c.project.set_social_account('Twitter', twitter_handle)
- if facebook_page != c.project.social_account('Facebook'):
- parsed = urlparse(facebook_page)
- if 'facebook.com' in parsed.netloc:
+ old_facebook = c.project.social_account('Facebook')
+ if not old_facebook or facebook_page != old_facebook.accounturl:
+ if not facebook_page or 'facebook.com' in urlparse(facebook_page).netloc:
h.log_action(log, 'change project facebook page').info('')
M.AuditLog.log('change project facebook page to %s', facebook_page)
c.project.set_social_account('Facebook', facebook_page)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ff04c8b2/Allura/allura/tests/unit/test_project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_project.py b/Allura/allura/tests/unit/test_project.py
index f83cfe9..396fdae 100644
--- a/Allura/allura/tests/unit/test_project.py
+++ b/Allura/allura/tests/unit/test_project.py
@@ -74,3 +74,11 @@ class TestProject(unittest.TestCase):
actual = [(e.label, e.url, len(e.matching_urls)) for e in entries]
self.assertEqual(expected, actual)
self.assertEqual(entries[0].matching_urls, expected_ticket_urls)
+
+ def test_social_account(self):
+ p = M.Project()
+ self.assertIsNone(p.social_account('Twitter'))
+
+ p.set_social_account('Twitter', 'http://twitter.com/allura')
+ self.assertEqual(p.social_account('Twitter').accounturl, 'http://twitter.com/allura')
+ self.assertEqual(p.twitter_handle, 'http://twitter.com/allura')
\ No newline at end of file
[29/44] git commit: [#6845] Preserve inter-project links when
importing from GC
Posted by jo...@apache.org.
[#6845] Preserve inter-project links when importing from GC
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/a069ca45
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a069ca45
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a069ca45
Branch: refs/heads/cj/6815
Commit: a069ca45307c1e4aafee00d0620130221017ddce
Parents: 7ed59a1
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Nov 12 18:13:26 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 19:15:29 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/google/__init__.py | 36 +++++++++++++++-----
.../tests/data/google/test-issue.html | 2 +-
.../tests/google/functional/test_tracker.py | 4 +--
.../tests/google/test_extractor.py | 6 ++--
4 files changed, 34 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a069ca45/ForgeImporters/forgeimporters/google/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/__init__.py b/ForgeImporters/forgeimporters/google/__init__.py
index 261b9f9..7a75eaf 100644
--- a/ForgeImporters/forgeimporters/google/__init__.py
+++ b/ForgeImporters/forgeimporters/google/__init__.py
@@ -52,21 +52,41 @@ def _as_text(node, chunks=None):
_as_text(n, chunks)
return ''.join(chunks)
-def _as_markdown(tag):
+def _as_markdown(tag, project_name):
fragments = []
for fragment in tag:
if getattr(fragment, 'name', None) == 'a':
href = urlparse(fragment['href'])
qs = parse_qs(href.query)
- if not href.netloc and 'id' in qs:
+ gc_link = not href.netloc or href.netloc == 'code.google.com'
+ target_project = href.path.split('/')[2]
+ internal_link = target_project == project_name
+ if gc_link and internal_link and 'id' in qs:
+ # rewrite issue 123 project-internal issue links
fragment = '[%s](#%s)' % (fragment.text, qs['id'][0])
- elif not href.netloc and 'r' in qs:
+ elif gc_link and internal_link and 'r' in qs:
+ # rewrite r123 project-internal revision links
fragment = '[r%s]' % qs['r'][0]
+ elif gc_link:
+ # preserve GC-internal links (probably issue PROJECT:123 inter-project issue links)
+ fragment = '[%s](%s)' % (
+ h.plain2markdown(fragment.text, preserve_multiple_spaces=True, has_html_entities=True),
+ urljoin('https://code.google.com/p/%s/issues/' % project_name, fragment['href']),
+ )
else:
+ # un-link all others
fragment = h.plain2markdown(fragment.text, preserve_multiple_spaces=True, has_html_entities=True)
elif getattr(fragment, 'name', None) == 'i':
+ # preserve styling of "(No comment was entered for this change.)" messages
fragment = '*%s*' % h.plain2markdown(fragment.text, preserve_multiple_spaces=True, has_html_entities=True)
+ elif getattr(fragment, 'name', None) == 'b':
+ # preserve styling of issue template
+ fragment = '**%s**' % h.plain2markdown(fragment.text, preserve_multiple_spaces=True, has_html_entities=True)
+ elif getattr(fragment, 'name', None) == 'br':
+ # preserve forced line-breaks
+ fragment = '\n'
else:
+ # convert all others to plain MD
fragment = h.plain2markdown(str(fragment), preserve_multiple_spaces=True, has_html_entities=True)
fragments.append(fragment)
return ''.join(fragments).strip()
@@ -203,7 +223,7 @@ class GoogleCodeProjectExtractor(ProjectExtractor):
return bs.text
def get_issue_description(self):
- return _as_markdown(self.page.find(id='hc0').pre)
+ return _as_markdown(self.page.find(id='hc0').pre, self.project_name)
def get_issue_created_date(self):
return self.page.find(id='hc0').find('span', 'date').get('title')
@@ -211,7 +231,7 @@ class GoogleCodeProjectExtractor(ProjectExtractor):
def get_issue_mod_date(self):
comments = self.page.findAll('div', 'issuecomment')
if comments:
- last_update = Comment(comments[-1])
+ last_update = Comment(comments[-1], self.project_name)
return last_update.created_date
else:
return self.get_issue_created_date()
@@ -250,7 +270,7 @@ class GoogleCodeProjectExtractor(ProjectExtractor):
def iter_comments(self):
for comment in self.page.findAll('div', 'issuecomment'):
- yield Comment(comment)
+ yield Comment(comment, self.project_name)
class UserLink(object):
def __init__(self, tag):
@@ -283,10 +303,10 @@ def _get_attachments(tag):
return []
class Comment(object):
- def __init__(self, tag):
+ def __init__(self, tag, project_name):
self.author = UserLink(tag.find('span', 'author').find(True, 'userlink'))
self.created_date = tag.find('span', 'date').get('title')
- self.body = _as_markdown(tag.find('pre'))
+ self.body = _as_markdown(tag.find('pre'), project_name)
self._get_updates(tag)
self.attachments = _get_attachments(tag)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a069ca45/ForgeImporters/forgeimporters/tests/data/google/test-issue.html
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/data/google/test-issue.html b/ForgeImporters/forgeimporters/tests/data/google/test-issue.html
index 374c0e8..c6bce0a 100644
--- a/ForgeImporters/forgeimporters/tests/data/google/test-issue.html
+++ b/ForgeImporters/forgeimporters/tests/data/google/test-issue.html
@@ -452,7 +452,7 @@ Last comment
<a name="c4" href="/p/allura-google-importer/issues/detail?id=6#c4">#4</a>
<a class="userlink" href="/u/101557263855536553789/">john...@gmail.com</a></span>
<pre>
-Oh, I forgot one
+Oh, I forgot one (with an inter-project reference to <a href="/p/other-project/issues/detail?id=1">issue other-project:1</a>)
</pre>
<div class="updates">
<div class="round4"></div>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a069ca45/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py b/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
index 2e52be6..c22f7d0 100644
--- a/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
@@ -41,7 +41,7 @@ class TestGCTrackerImporter(TestCase):
def _make_extractor(self, html):
with mock.patch.object(base.h, 'urlopen') as urlopen:
urlopen.return_value = ''
- extractor = google.GoogleCodeProjectExtractor('my-project', 'project_info')
+ extractor = google.GoogleCodeProjectExtractor('allura-google-importer', 'project_info')
extractor.page = BeautifulSoup(html)
extractor.url = "http://test/issue/?id=1"
return extractor
@@ -241,7 +241,7 @@ class TestGCTrackerImporter(TestCase):
'text': (
'*Originally posted by:* [john...@gmail.com](http://code.google.com/u/101557263855536553789/)\n'
'\n'
- 'Oh, I forgot one\n'
+ 'Oh, I forgot one \\(with an inter\\-project reference to [issue other\\-project:1](https://code.google.com/p/other-project/issues/detail?id=1)\\)\n'
'\n'
'**Labels:** OpSys-OSX'
),
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a069ca45/ForgeImporters/forgeimporters/tests/google/test_extractor.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/test_extractor.py b/ForgeImporters/forgeimporters/tests/google/test_extractor.py
index 032e122..78bde81 100644
--- a/ForgeImporters/forgeimporters/tests/google/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/google/test_extractor.py
@@ -124,7 +124,7 @@ class TestGoogleCodeProjectExtractor(TestCase):
def _make_extractor(self, html):
from BeautifulSoup import BeautifulSoup
with mock.patch.object(base.ProjectExtractor, 'urlopen'):
- extractor = google.GoogleCodeProjectExtractor('my-project')
+ extractor = google.GoogleCodeProjectExtractor('allura-google-importer')
extractor.page = BeautifulSoup(html)
extractor.get_page = lambda pagename: extractor.page
extractor.url="http://test/source/browse"
@@ -278,7 +278,7 @@ class TestGoogleCodeProjectExtractor(TestCase):
'author.name': 'john...@gmail.com',
'author.url': 'http://code.google.com/u/101557263855536553789/',
'created_date': 'Thu Aug 8 15:36:57 2013',
- 'body': 'Oh, I forgot one',
+ 'body': 'Oh, I forgot one \\(with an inter-project reference to [issue other-project:1](https://code.google.com/p/other-project/issues/detail?id=1)\\)',
'updates': {'Labels:': 'OpSys-OSX'},
'attachments': [],
},
@@ -390,7 +390,7 @@ class TestComment(TestCase):
def test_init(self):
from BeautifulSoup import BeautifulSoup
html = BeautifulSoup(self.html)
- comment = google.Comment(html.find('div', 'issuecomment'))
+ comment = google.Comment(html.find('div', 'issuecomment'), 'pychess')
self.assertEqual(comment.updates, {
u'Summary:': u'Make PyChess keyboard accessible',
u'Status:': u'Accepted',
[30/44] git commit: [#6845] Preserve links in GC ticket import and
fixed Index error on non-GC links
Posted by jo...@apache.org.
[#6845] Preserve links in GC ticket import and fixed Index error on non-GC links
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d1aa716b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d1aa716b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d1aa716b
Branch: refs/heads/cj/6815
Commit: d1aa716b2df39fc137081fae6bcb893d95b61706
Parents: a069ca4
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Nov 13 18:23:19 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 19:15:29 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/google/__init__.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d1aa716b/ForgeImporters/forgeimporters/google/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/__init__.py b/ForgeImporters/forgeimporters/google/__init__.py
index 7a75eaf..60f96c3 100644
--- a/ForgeImporters/forgeimporters/google/__init__.py
+++ b/ForgeImporters/forgeimporters/google/__init__.py
@@ -59,7 +59,8 @@ def _as_markdown(tag, project_name):
href = urlparse(fragment['href'])
qs = parse_qs(href.query)
gc_link = not href.netloc or href.netloc == 'code.google.com'
- target_project = href.path.split('/')[2]
+ path_parts = href.path.split('/')
+ target_project = path_parts[2] if gc_link and len(path_parts) >= 3 else ''
internal_link = target_project == project_name
if gc_link and internal_link and 'id' in qs:
# rewrite issue 123 project-internal issue links
@@ -74,8 +75,8 @@ def _as_markdown(tag, project_name):
urljoin('https://code.google.com/p/%s/issues/' % project_name, fragment['href']),
)
else:
- # un-link all others
- fragment = h.plain2markdown(fragment.text, preserve_multiple_spaces=True, has_html_entities=True)
+ # convert all other links to Markdown syntax
+ fragment = '[%s](%s)' % (fragment.text, fragment['href'])
elif getattr(fragment, 'name', None) == 'i':
# preserve styling of "(No comment was entered for this change.)" messages
fragment = '*%s*' % h.plain2markdown(fragment.text, preserve_multiple_spaces=True, has_html_entities=True)
[21/44] git commit: [#6622] ticket:469 fixed regex'es and tests
Posted by jo...@apache.org.
[#6622] ticket:469 fixed regex'es and tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/ad1f2c33
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ad1f2c33
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ad1f2c33
Branch: refs/heads/cj/6815
Commit: ad1f2c335f1a51ced3250af4a39cbd97eaf9e4b3
Parents: bf301e0
Author: coldmind <so...@yandex.ru>
Authored: Thu Nov 7 13:08:11 2013 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:57 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 23 +++++++-----
.../forgeimporters/github/tests/test_wiki.py | 11 ++++--
ForgeImporters/forgeimporters/github/utils.py | 37 +++++++-------------
.../forgeimporters/tests/github/test_tracker.py | 25 ++++++++-----
4 files changed, 53 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ad1f2c33/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 d60cb0d..cc02e6b 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -85,15 +85,22 @@ for (var i = 0; i < a.length; i++) {
console.log(i);
}
```'''
- result = u'''~~~~
-print "Hello!"
-~~~~
+ result = u'''<br>
+
+ :::python
+ print "Hello!"
+
+<br>
+
Two code blocks here!
-~~~~
-for (var i = 0; i < a.length; i++) {
- console.log(i);
-}
-~~~~'''
+
+<br>
+
+ for (var i = 0; i < a.length; i++) {
+ console.log(i);
+ }
+
+<br>'''
assert_equal(self.conv.convert(text).strip(), result)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ad1f2c33/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 818f8ee..ee37c38 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -318,9 +318,14 @@ Our website is <http://sf.net>.
[[Escaped Tag]]
-~~~~
-codeblock
-~~~~
+
+<br>
+
+ :::python
+ codeblock
+
+<br>
+
ticket [#1]
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ad1f2c33/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index 17e28ac..5d64666 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -6,7 +6,7 @@ class GitHubMarkdownConverter(object):
def __init__(self, gh_user, gh_project):
self.gh_project = '%s/%s' % (gh_user, gh_project)
self.gh_base_url = u'https://github.com/'
- self.code_patterns = ['```']
+ self.code_patterns = ['```', '~~~~~']
def convert(self, text):
lines = self._parse_lines(text.split('\n'))
@@ -19,11 +19,15 @@ class GitHubMarkdownConverter(object):
nextline = False
for p in self.code_patterns:
if line.lstrip().startswith(p):
- _re = re.compile(r'\```(.*)')
- syntax = _re.findall(line)[0]
- if syntax and not syntax.isspace():
- new_lines.append(self._codeblock_syntax(syntax))
-
+ # this is extreme, but due to display bugs
+ # it's necessary
+ new_lines.append('\n<br>\n')
+
+ if p == '```':
+ _re = re.compile(r'\```(.*)')
+ syntax = _re.findall(line)[0]
+ if syntax and not syntax.isspace():
+ new_lines.append(self._codeblock_syntax(syntax))
in_block = not in_block
nextline = True
break
@@ -33,14 +37,9 @@ class GitHubMarkdownConverter(object):
if in_block:
new_lines.append(self._handle_code(line))
else:
- _re = re.compile(r'`\s*(.*?)`')
- is_inline_code = _re.findall(line)
-
if line.lstrip().startswith(' '):
# code block due to github syntax
continue
- elif is_inline_code and not is_inline_code[0].isspace():
- new_lines.append(self._handle_inline_code(line))
else:
new_lines.append(self._handle_non_code(line))
return new_lines
@@ -53,16 +52,6 @@ class GitHubMarkdownConverter(object):
text = ' ' + text
return text
- def _handle_inline_code(self, text):
- """Return a string that will replace ``text`` in the final text
- output. ``text`` is inline code.
-
- """
- _re = re.compile(r'`(\s*)(.*?)`')
- text = _re.sub(self._convert_inline_codeblock, text)
-
- return text
-
def _handle_non_code(self, text):
"""Return a string that will replace ``text`` in the final text
output. ``text`` is *not* code.
@@ -83,10 +72,10 @@ class GitHubMarkdownConverter(object):
_re = re.compile(r'(\b)(\S+)@([0-9a-f]{40})(\b)')
text = _re.sub(self._convert_user_sha, text)
- _re = re.compile(r'(\b)([0-9a-f]{40})(\b)')
+ _re = re.compile(r'(\s|^)([0-9a-f]{40})(\s|$)')
text = _re.sub(self._convert_sha, text)
- _re = re.compile(r'~~(.*)~~',)
+ _re = re.compile(r'~~(.*?)~~',)
text = _re.sub(self._convert_strikethrough, text)
return text
@@ -141,7 +130,7 @@ class GitHubMarkdownConverter(object):
return '<s>%s</s>' % m.group(1)
def _codeblock_syntax(self, text):
- return '\n :::%s' % text
+ return ' :::%s' % text
def _convert_inline_codeblock(self, m):
text = m.group(0)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ad1f2c33/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 bac2a1a..e305943 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
@@ -195,10 +195,14 @@ def hello(name):
Hello
-~~~~
-def hello(name):
- print "Hello, " + name
-~~~~'''
+
+<br>
+
+ :::python
+ def hello(name):
+ print "Hello, " + name
+
+<br>'''
issue = {
'body': body,
'title': 'title',
@@ -229,10 +233,15 @@ def hello(name):
Hello
-~~~~
-def hello(name):
- print "Hello, " + name
-~~~~'''
+
+<br>
+
+ :::python
+ def hello(name):
+ print "Hello, " + name
+
+<br>
+'''
issue = {'comments_url': '/comments'}
extractor.iter_comments.return_value = [
{
[38/44] git commit: [#6656] ticket:437 GitHub OAuth flow
Posted by jo...@apache.org.
[#6656] ticket:437 GitHub OAuth flow
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d1f23ad8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d1f23ad8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d1f23ad8
Branch: refs/heads/cj/6815
Commit: d1f23ad8cb3605cba94e59ad5ca6bf74d7b2fa04
Parents: 3c07c83
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Oct 25 17:24:37 2013 +0300
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 20:43:46 2013 +0000
----------------------------------------------------------------------
Allura/development.ini | 4 ++
.../forgeimporters/github/__init__.py | 41 ++++++++++++++++++++
ForgeImporters/forgeimporters/github/project.py | 5 ++-
requirements-common.txt | 1 +
4 files changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d1f23ad8/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 2c701cb..848955a 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -157,6 +157,10 @@ bulk_export_download_instructions = Sample instructions for {project}
importer_upload_path = /tmp/importer_upload/{nbhd}/{project}
+# GitHub importer keys
+# github_importer.client_id =
+# github_importer.client_secret =
+
# space-separated list of tool names that are valid options
# for project admins to set for their 'support_page' field
# this field is not used by default in Allura, so this option
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d1f23ad8/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index 951d670..a92f4a1 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -22,6 +22,11 @@ import time
import urllib2
from datetime import datetime
+from tg import config, session, redirect, request, expose
+from tg.decorators import without_trailing_slash
+from pylons import tmpl_context as c
+from requests_oauthlib import OAuth2Session
+
from forgeimporters import base
log = logging.getLogger(__name__)
@@ -136,3 +141,39 @@ class GitHubProjectExtractor(base.ProjectExtractor):
def has_wiki(self):
return self.get_page('project_info').get('has_wiki')
+
+
+class GitHubOAuthMixin(object):
+ '''Support for github oauth web application flow.'''
+
+ def oauth_begin(self, controller_url):
+ '''controller_url is absolute url, refers the controller you mixed this class in'''
+ client_id = config.get('github_importer.client_id')
+ secret = config.get('github_importer.client_secret')
+ if not client_id or not secret:
+ return # GitHub app is not configured
+ if c.user.get_tool_data('GitHubProjectImport', 'token'):
+ return # token already exists, nothing to do
+ redirect_uri = controller_url.rstrip('/') + '/oauth_callback'
+ oauth = OAuth2Session(client_id, redirect_uri=redirect_uri)
+ auth_url, state = oauth.authorization_url('https://github.com/login/oauth/authorize')
+ session['github.oauth.state'] = state # Used in callback to prevent CSRF
+ session['github.oauth.redirect'] = controller_url
+ session.save()
+ redirect(auth_url)
+
+ @without_trailing_slash
+ @expose()
+ def oauth_callback(self, **kw):
+ client_id = config.get('github_importer.client_id')
+ secret = config.get('github_importer.client_secret')
+ if not client_id or not secret:
+ return # GitHub app is not configured
+ oauth = OAuth2Session(client_id, state=session.get('github.oauth.state'))
+ token = oauth.fetch_token(
+ 'https://github.com/login/oauth/access_token',
+ client_secret=secret,
+ authorization_response=request.url
+ )
+ c.user.set_tool_data('GitHubProjectImport', token=token['access_token'])
+ redirect(session.get('github.oauth.redirect', '/'))
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d1f23ad8/ForgeImporters/forgeimporters/github/project.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/project.py b/ForgeImporters/forgeimporters/github/project.py
index e04590a..29df780 100644
--- a/ForgeImporters/forgeimporters/github/project.py
+++ b/ForgeImporters/forgeimporters/github/project.py
@@ -23,9 +23,11 @@ from tg import expose, validate
from tg.decorators import with_trailing_slash
from allura.lib.decorators import require_post
+from allura.lib import helpers as h
from .. import base
from . import tasks
+from . import GitHubOAuthMixin
log = logging.getLogger(__name__)
@@ -37,7 +39,7 @@ class GitHubProjectForm(base.ProjectImportForm):
'invalid': 'Valid symbols are: letters, numbers, dashes, underscores and periods',
})
-class GitHubProjectImporter(base.ProjectImporter):
+class GitHubProjectImporter(base.ProjectImporter, GitHubOAuthMixin):
source = 'GitHub'
index_template = 'jinja:forgeimporters.github:templates/project.html'
@@ -51,6 +53,7 @@ class GitHubProjectImporter(base.ProjectImporter):
@with_trailing_slash
@expose(index_template)
def index(self, **kw):
+ self.oauth_begin(h.absurl('/p/import_project/github/'))
return super(self.__class__, self).index(**kw)
@require_post()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d1f23ad8/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index 1b1d2f6..685f437 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -39,6 +39,7 @@ python-openid==2.2.5
python-oembed==0.2.1
pytidylib==0.2.1
requests==1.2.3
+requests-oauthlib==0.4.0
# for taskd proc name switching
setproctitle==1.1.7
# dep of pypeline
[20/44] git commit: [#6622] ticket:494 handle ``` without a blank
line before it
Posted by jo...@apache.org.
[#6622] ticket:494 handle ``` without a blank line before it
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/479c43e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/479c43e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/479c43e4
Branch: refs/heads/cj/6815
Commit: 479c43e4cb025e4751a27871e1307ab7f382c963
Parents: 9efb689
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 13 12:11:42 2013 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:57 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 32 ++++++++++++++++++++
.../forgeimporters/github/tests/test_wiki.py | 1 -
ForgeImporters/forgeimporters/github/utils.py | 9 ++++--
.../forgeimporters/tests/github/test_tracker.py | 2 --
4 files changed, 38 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/479c43e4/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 f31bba8..432c536 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -95,3 +95,35 @@ Two code blocks here!
}'''
assert_equal(self.conv.convert(text).strip(), result)
+
+ def test_code_blocks_without_newline_before(self):
+ text = u'''
+There are some code snippet:
+```
+print 'Hello'
+```
+Pretty cool, ha?'''
+
+ result = u'''
+There are some code snippet:
+
+ print 'Hello'
+Pretty cool, ha?'''
+ assert_equal(self.conv.convert(text).strip(), result.strip())
+ text = text.replace('```', '~~~')
+ assert_equal(self.conv.convert(text).strip(), result.strip())
+
+ text = u'''
+There are some code snippet:
+```python
+print 'Hello'
+```
+Pretty cool, ha?'''
+
+ result = u'''
+There are some code snippet:
+
+ :::python
+ print 'Hello'
+Pretty cool, ha?'''
+ assert_equal(self.conv.convert(text).strip(), result.strip())
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/479c43e4/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 b9b18bd..dec92a4 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -318,7 +318,6 @@ Our website is <http://sf.net>.
[[Escaped Tag]]
-
:::python
codeblock
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/479c43e4/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index cfc3a59..0beaba6 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -6,7 +6,7 @@ class GitHubMarkdownConverter(object):
def __init__(self, gh_user, gh_project):
self.gh_project = '%s/%s' % (gh_user, gh_project)
self.gh_base_url = u'https://github.com/'
- self.code_patterns = ['```', '~~~~~']
+ self.code_patterns = ['```', '~~~']
def convert(self, text):
lines = self._parse_lines(text.split('\n'))
@@ -15,10 +15,13 @@ class GitHubMarkdownConverter(object):
def _parse_lines(self, lines):
in_block = False
new_lines = []
- for line in lines:
+ for i, line in enumerate(lines):
nextline = False
for p in self.code_patterns:
if line.startswith(p):
+ prev_line = lines[i-1].strip() if (i-1) >= 0 else ''
+ if len(prev_line) > 0 and not in_block:
+ new_lines.append('')
if p == '```':
syntax = line.lstrip('`').strip()
if syntax:
@@ -135,4 +138,4 @@ class GitHubMarkdownConverter(object):
return '<s>%s</s>' % m.group(1)
def _codeblock_syntax(self, text):
- return '\n :::%s' % text
+ return ' :::%s' % text
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/479c43e4/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 e991382..e3da3c7 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
@@ -195,7 +195,6 @@ def hello(name):
Hello
-
:::python
def hello(name):
print "Hello, " + name'''
@@ -230,7 +229,6 @@ def hello(name):
Hello
-
:::python
def hello(name):
print "Hello, " + name'''
[26/44] git commit: [#6622] add license header
Posted by jo...@apache.org.
[#6622] add license header
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0ec51d77
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0ec51d77
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0ec51d77
Branch: refs/heads/cj/6815
Commit: 0ec51d77844b67e05fd6ad1713f4a1a4ccb3f0b1
Parents: 479c43e
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Nov 13 18:25:49 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 18:25:49 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 17 +++++++++++++++++
ForgeImporters/forgeimporters/github/utils.py | 17 +++++++++++++++++
2 files changed, 34 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0ec51d77/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 432c536..6ce7821 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
from nose.tools import assert_equal
from forgeimporters.github.utils import GitHubMarkdownConverter
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0ec51d77/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index 0beaba6..ec3d5ff 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
import re
[36/44] git commit: [#6656] ticket:437 Check rate limit values and
sleep until reset
Posted by jo...@apache.org.
[#6656] ticket:437 Check rate limit values and sleep until reset
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4d518a0f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4d518a0f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4d518a0f
Branch: refs/heads/cj/6815
Commit: 4d518a0f2c2e977d46f2cce6b7b81b82e6097516
Parents: d396c9e
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Oct 25 12:53:52 2013 +0300
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 20:43:45 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/__init__.py | 16 ++++++++--
.../tests/github/test_extractor.py | 31 ++++++++++++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4d518a0f/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index 5726326..4932697 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -18,6 +18,8 @@
import re
import logging
import json
+import time
+from datetime import datetime
from forgeimporters import base
@@ -48,8 +50,18 @@ class GitHubProjectExtractor(base.ProjectExtractor):
return url
def urlopen(self, url, **kw):
- url = self.add_token(url)
- return super(GitHubProjectExtractor, self).urlopen(url, **kw)
+ resp = super(GitHubProjectExtractor, self).urlopen(self.add_token(url), **kw)
+ remain = resp.info().get('X-RateLimit-Remaining')
+ if remain and int(remain) == 0:
+ reset = resp.info().get('X-RateLimit-Reset')
+ limit = resp.info().get('X-RateLimit-Limit')
+ reset = datetime.utcfromtimestamp(int(reset))
+ now = datetime.utcnow()
+ log.warn('Rate limit exceeded (%s requests/hour). '
+ 'Sleeping until %s UTC' % (limit, reset))
+ time.sleep((reset - now).total_seconds())
+ self.urlopen(url, **kw)
+ return resp
def get_next_page_url(self, link):
if not link:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4d518a0f/ForgeImporters/forgeimporters/tests/github/test_extractor.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/github/test_extractor.py b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
index a26438a..b3ad2f2 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
@@ -16,6 +16,7 @@
# under the License.
import json
+from datetime import datetime
from unittest import TestCase
from mock import patch, Mock
@@ -149,3 +150,33 @@ class TestGitHubProjectExtractor(TestCase):
e.urlopen(url)
request = urlopen.call_args[0][0]
self.assertEqual(request.get_full_url(), url + '&access_token=abc')
+
+ @patch('forgeimporters.base.h.urlopen')
+ @patch('forgeimporters.github.time.sleep')
+ @patch('forgeimporters.github.log')
+ def test_urlopen_rate_limit(self, log, sleep, urlopen):
+ limit_exceeded_headers = {
+ 'X-RateLimit-Limit': '10',
+ 'X-RateLimit-Remaining': '0',
+ 'X-RateLimit-Reset': '1382693522',
+ }
+ response_limit_exceeded = StringIO('{}')
+ response_limit_exceeded.info = lambda: limit_exceeded_headers
+ response_ok = StringIO('{}')
+ response_ok.info = lambda: {}
+ results = [response_limit_exceeded, response_ok]
+ urlopen.side_effect = lambda *a, **kw: results.pop(0)
+ e = github.GitHubProjectExtractor('test_project')
+ e.get_page('fake')
+ self.assertEqual(sleep.call_count, 1)
+ self.assertEqual(urlopen.call_count, 2)
+ log.warn.assert_called_once_with(
+ 'Rate limit exceeded (10 requests/hour). '
+ 'Sleeping until 2013-10-25 09:32:02 UTC'
+ )
+ sleep.reset_mock(); urlopen.reset_mock(); log.warn.reset_mock()
+ urlopen.side_effect = lambda *a, **kw: response_ok
+ e.get_page('fake 2')
+ self.assertEqual(sleep.call_count, 0)
+ self.assertEqual(urlopen.call_count, 1)
+ self.assertEqual(log.warn.call_count, 0)
[13/44] git commit: [#6622] ticket:469 use new converter now
Posted by jo...@apache.org.
[#6622] ticket:469 use new converter now
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f9db5f9d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f9db5f9d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f9db5f9d
Branch: refs/heads/cj/6815
Commit: f9db5f9d4d625cea535d4f1bdc4fcd96066cdb44
Parents: 4b7b2b0
Author: coldmind <so...@yandex.ru>
Authored: Wed Nov 6 18:29:50 2013 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:56 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/utils.py | 50 ++++++++++++++++++++--
1 file changed, 46 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f9db5f9d/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index 63a55e4..03dfe1b 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -6,8 +6,52 @@ class GitHubMarkdownConverter(object):
def __init__(self, gh_user, gh_project):
self.gh_project = '%s/%s' % (gh_user, gh_project)
self.gh_base_url = u'https://github.com/'
+ self.code_patterns = ['```']
def convert(self, text):
+ lines = self._parse_lines(text.split('\n'))
+ return '\n'.join(lines)
+
+ def _parse_lines(self, lines):
+ in_block = False
+ new_lines = []
+ for line in lines:
+ nextline = False
+ for p in self.code_patterns:
+ if line.lstrip().startswith(p):
+ _re = re.compile(r'\```(.*)')
+ syntax = _re.findall(line)[0]
+ if syntax and not syntax.isspace():
+ new_lines.append(self._codeblock_syntax(syntax))
+
+ in_block = not in_block
+ nextline = True
+ break
+ if nextline:
+ continue
+
+ if in_block:
+ new_lines.append(self._handle_code(line))
+ else:
+ if line.lstrip().startswith(' '):
+ new_lines.append(self._handle_code(line))
+ else:
+ new_lines.append(self._handle_non_code(line))
+ return new_lines
+
+ def _handle_code(self, text):
+ """Return a string that will replace ``text`` in the final text
+ output. ``text`` is code.
+
+ """
+ text = ' ' + text
+ return text
+
+ def _handle_non_code(self, text):
+ """Return a string that will replace ``text`` in the final text
+ output. ``text`` is *not* code.
+
+ """
_re = re.compile(r'(\s|^)(\S+)/(\S+)#(\d+)(\s|$)')
text = _re.sub(self._convert_user_repo_ticket, text)
@@ -29,8 +73,6 @@ class GitHubMarkdownConverter(object):
_re = re.compile(r'~~(.*)~~',)
text = _re.sub(self._convert_strikethrough, text)
- _re = re.compile(r'```\w*(.*?)```', re.DOTALL)
- text = _re.sub(self._convert_codeblock, text)
return text
def _gh_commit_url(self, project, sha, title):
@@ -82,5 +124,5 @@ class GitHubMarkdownConverter(object):
def _convert_strikethrough(self, m):
return '<s>%s</s>' % m.group(1)
- def _convert_codeblock(self, m):
- return '~~~~%s~~~~'% m.group(1)
+ def _codeblock_syntax(self, text):
+ return '\n :::%s' % text
\ No newline at end of file
[34/44] git commit: [#6826] ticket:484 Mass edit emails
Posted by jo...@apache.org.
[#6826] ticket:484 Mass edit emails
Reply-to field has updated to use config['forgemail.return_path']
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/2c6339ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/2c6339ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/2c6339ab
Branch: refs/heads/cj/6815
Commit: 2c6339ab4592bcca37ca7f64941ac95d433faefa
Parents: 4b1e60d
Author: Andrej Aleksandrov <pi...@gmail.com>
Authored: Tue Nov 12 10:23:34 2013 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 20:06:16 2013 +0000
----------------------------------------------------------------------
ForgeTracker/forgetracker/model/ticket.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2c6339ab/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 1360c84..a7b17f8 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -36,6 +36,8 @@ from ming.orm import FieldProperty, ForeignIdProperty, RelationProperty
from ming.orm.declarative import MappedClass
from ming.orm.ormsession import ThreadLocalORMSession
+from tg import config as tg_config
+
from allura.model import (
ACE,
DENY_ALL,
@@ -407,7 +409,7 @@ class Globals(MappedClass):
mail = dict(
sender = c.project.app_instance(self.app_config).email_address,
fromaddr = str(c.user._id),
- reply_to = str(c.user._id),
+ reply_to = tg_config['forgemail.return_path'],
subject = '[%s:%s] Mass edit changes by %s' % (c.project.shortname,
self.app_config.options.mount_point,
c.user.display_name),
[14/44] git commit: [#6622] ticket:435 Add newline at the begining of
ticket comments
Posted by jo...@apache.org.
[#6622] ticket:435 Add newline at the begining of ticket comments
After 'Originally posted by' in ticket comments should be extra newline.
Without it some markup doesn't properly converted (e.g. code blocks).
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4b7b2b0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4b7b2b0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4b7b2b0c
Branch: refs/heads/cj/6815
Commit: 4b7b2b0c21f6ec19170cde47ab68b8cbc3717ccb
Parents: d2d337b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 17:23:31 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:56 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/tracker.py | 2 +-
ForgeImporters/forgeimporters/tests/github/test_tracker.py | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b7b2b0c/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index c2141ce..5e3c134 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -180,7 +180,7 @@ class GitHubTrackerImporter(ToolImporter):
for comment in extractor.iter_comments(issue):
body, attachments = self._get_attachments(comment['body'])
if comment['user']:
- posted_by = u'*Originally posted by:* {}\n'.format(
+ posted_by = u'*Originally posted by:* {}\n\n'.format(
self.get_user_link(comment['user']['login']))
body = posted_by + body
p = ticket.discussion_thread.add_post(
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b7b2b0c/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 43a3bb6..bac2a1a 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
@@ -138,7 +138,7 @@ class TestTrackerImporter(TestCase):
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',
+ text='*Originally posted by:* [me](https://github.com/me)\n\nhello',
timestamp=datetime(2013, 8, 26, 16, 57, 53),
ignore_security=True,
))
@@ -226,6 +226,7 @@ def hello(name):
print "Hello, " + name
```'''
body_converted = '''*Originally posted by:* [me](https://github.com/me)
+
Hello
~~~~
[41/44] git commit: [#6656] ticket:437 OAuth tests
Posted by jo...@apache.org.
[#6656] ticket:437 OAuth tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/5f434893
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5f434893
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5f434893
Branch: refs/heads/cj/6815
Commit: 5f434893f43098a8720eb9b34c8b995da13bb72a
Parents: ac8fa2c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Oct 25 17:12:28 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 20:47:42 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_code.py | 7 ++++
.../forgeimporters/github/tests/test_tracker.py | 8 ++++
.../forgeimporters/github/tests/test_wiki.py | 7 ++++
.../tests/github/functional/test_github.py | 44 ++++++++++++++++++++
.../forgeimporters/tests/github/test_tasks.py | 3 +-
5 files changed, 68 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5f434893/ForgeImporters/forgeimporters/github/tests/test_code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_code.py b/ForgeImporters/forgeimporters/github/tests/test_code.py
index 4ad8dac..7c85058 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_code.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_code.py
@@ -23,6 +23,7 @@ from allura.tests import TestController
from allura.tests.decorators import with_tool
from allura import model as M
from forgeimporters.github.code import GitHubRepoImporter
+from forgeimporters.github import GitHubOAuthMixin
# important to be distinct from 'test' which ForgeGit uses, so that the tests can run in parallel and not clobber each other
@@ -105,3 +106,9 @@ class TestGitHubImportController(TestController, TestCase):
status=302).follow()
self.assertIn('Please wait and try again', r)
self.assertEqual(import_tool.post.call_count, 0)
+
+ @with_git
+ @patch.object(GitHubOAuthMixin, 'oauth_begin')
+ def test_oauth(self, oauth_begin):
+ r = self.app.get('/p/{}/admin/ext/import/github-repo/'.format(test_project_with_repo))
+ oauth_begin.assert_called_once()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5f434893/ForgeImporters/forgeimporters/github/tests/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_tracker.py b/ForgeImporters/forgeimporters/github/tests/test_tracker.py
index 938a194..d63b4d6 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_tracker.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_tracker.py
@@ -23,6 +23,8 @@ from allura.tests import TestController
from allura.tests.decorators import with_tool
from allura import model as M
+from forgeimporters.github import GitHubOAuthMixin
+
# important to be distinct from 'test' which ForgeTracker uses, so that the tests can run in parallel and not clobber each other
test_project_with_tracker = 'test2'
with_tracker = with_tool(test_project_with_tracker, 'tickets', 'spooky-issues', 'tickets')
@@ -69,3 +71,9 @@ class TestGitHubTrackerImportController(TestController, TestCase):
r = self.app.post(self.url + 'create', params, status=302).follow()
self.assertIn('Please wait and try again', r)
self.assertEqual(import_tool.post.call_count, 0)
+
+ @with_tracker
+ @patch.object(GitHubOAuthMixin, 'oauth_begin')
+ def test_oauth(self, oauth_begin):
+ r = self.app.get(self.url)
+ oauth_begin.assert_called_once()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5f434893/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 dec92a4..70ea74d 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -29,6 +29,7 @@ from allura.tests.decorators import with_tool, without_module
from alluratest.controller import setup_basic_test
from forgeimporters.github.wiki import GitHubWikiImporter
from forgeimporters.github.utils import GitHubMarkdownConverter
+from forgeimporters.github import GitHubOAuthMixin
# important to be distinct from 'test' which ForgeWiki uses, so that the tests can run in parallel and not clobber each other
@@ -558,3 +559,9 @@ class TestGitHubWikiImportController(TestController, TestCase):
r = self.app.post(self.url + 'create', params, status=302).follow()
self.assertIn('Please wait and try again', r)
self.assertEqual(import_tool.post.call_count, 0)
+
+ @with_wiki
+ @patch.object(GitHubOAuthMixin, 'oauth_begin')
+ def test_oauth(self, oauth_begin):
+ r = self.app.get(self.url)
+ oauth_begin.assert_called_once()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5f434893/ForgeImporters/forgeimporters/tests/github/functional/test_github.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/github/functional/test_github.py b/ForgeImporters/forgeimporters/tests/github/functional/test_github.py
index afc9bd0..a9c5052 100644
--- a/ForgeImporters/forgeimporters/tests/github/functional/test_github.py
+++ b/ForgeImporters/forgeimporters/tests/github/functional/test_github.py
@@ -15,8 +15,13 @@
# specific language governing permissions and limitations
# under the License.
+import tg
+from mock import patch, call, Mock
+from nose.tools import assert_equal
from unittest import TestCase
+
from allura.tests import TestController
+from allura import model as M
class TestGitHubImportController(TestController, TestCase):
@@ -35,3 +40,42 @@ class TestGitHubImportController(TestController, TestCase):
r = self.app.post('/p/import_project/github/process', extra_environ=dict(username='*anonymous'), status=302)
self.assertIn('/auth/', r.location)
+
+
+class TestGitHubOAuth(TestController):
+
+ def setUp(self):
+ super(TestGitHubOAuth, self).setUp()
+ tg.config['github_importer.client_id'] = 'client_id'
+ tg.config['github_importer.client_secret'] = 'secret'
+
+ @patch('forgeimporters.github.OAuth2Session')
+ @patch('forgeimporters.github.session')
+ def test_oauth_flow(self, session, oauth):
+ redirect = 'http://localhost/p/import_project/github/oauth_callback'
+ oauth_instance = Mock()
+ oauth_instance.authorization_url.return_value = (redirect, 'state')
+ oauth_instance.fetch_token.return_value = {'access_token': 'abc'}
+ oauth.return_value = oauth_instance
+
+ user = M.User.by_username('test-admin')
+ assert_equal(user.get_tool_data('GitHubProjectImport', 'token'), None)
+ r = self.app.get('/p/import_project/github/')
+ assert_equal(r.status_int, 302)
+ assert_equal(r.location, redirect)
+ session.__setitem__.assert_has_calls([
+ call('github.oauth.state', 'state'),
+ call('github.oauth.redirect', 'http://localhost/p/import_project/github/')
+ ])
+ session.save.assert_called_once()
+
+ r = self.app.get(redirect)
+ session.get.assert_has_calls([
+ call('github.oauth.state'),
+ call('github.oauth.redirect', '/')
+ ])
+ user = M.User.by_username('test-admin')
+ assert_equal(user.get_tool_data('GitHubProjectImport', 'token'), 'abc')
+
+ r = self.app.get('/p/import_project/github/')
+ assert_equal(r.status_int, 200) # token in user data, so oauth isn't triggered
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5f434893/ForgeImporters/forgeimporters/tests/github/test_tasks.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/github/test_tasks.py b/ForgeImporters/forgeimporters/tests/github/test_tasks.py
index 86b321e..cf58644 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tasks.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tasks.py
@@ -25,8 +25,9 @@ from ...github import tasks
@mock.patch.object(tasks, 'c')
def test_import_project_info(c, session, ghpe):
c.project = mock.Mock(name='project')
+ c.user = mock.Mock(name='user')
tasks.import_project_info('my-project')
- ghpe.assert_called_once_with('my-project')
+ ghpe.assert_called_once_with('my-project', user=c.user)
ghpe.return_value.get_summary.assert_called_once_with()
ghpe.return_value.get_homepage.assert_called_once_with()
session.flush_all.assert_called_once_with()
[33/44] git commit: [#6852] ticket:476 changed style of actions block
to trim text
Posted by jo...@apache.org.
[#6852] ticket:476 changed style of actions block to trim text
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4b1e60d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4b1e60d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4b1e60d2
Branch: refs/heads/cj/6815
Commit: 4b1e60d2ea0b8738ccf5bc9b4364abb99f1e0bdc
Parents: bf4195f
Author: Yaroslav Sokolovsky <ya...@gmail.com>
Authored: Fri Nov 8 15:45:50 2013 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 19:21:58 2013 +0000
----------------------------------------------------------------------
Allura/allura/nf/allura/css/site_style.css | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4b1e60d2/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 3c132ad..4cee523 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2002,9 +2002,14 @@ nav .ico {
.pad h2.dark small {
text-transform: none;
position: absolute;
- right: 5px;
+ right: 0px;
top: 5px;
+ padding-right: 5px;
text-align: center;
+ background-color: #555555;
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #666666), color-stop(100%, #555555));
+ background-image: -moz-linear-gradient(top, #666666 0%, #555555 100%);
+ background-image: linear-gradient(top, #666666 0%, #555555 100%);
}
.pad h2.dark small a {
margin: 0 10px;
@@ -2074,6 +2079,7 @@ nav .ico {
.pad h2.title {
font-weight: normal;
margin-bottom: 1.5em;
+ white-space: nowrap;
}
.pad .paginate {
margin: 0 0 0 20px;
[37/44] git commit: [#6656] ticket:437 More careful rate limit
checking
Posted by jo...@apache.org.
[#6656] ticket:437 More careful rate limit checking
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/3c07c836
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3c07c836
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3c07c836
Branch: refs/heads/cj/6815
Commit: 3c07c83643389b4402fb2c9b830ce7f835114517
Parents: 4d518a0
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Oct 25 16:14:50 2013 +0300
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 20:43:45 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/__init__.py | 32 +++++++++++++-----
.../tests/github/test_extractor.py | 35 +++++++++++++++++---
2 files changed, 54 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c07c836/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index 4932697..951d670 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -19,6 +19,7 @@ import re
import logging
import json
import time
+import urllib2
from datetime import datetime
from forgeimporters import base
@@ -49,18 +50,31 @@ class GitHubProjectExtractor(base.ProjectExtractor):
url += glue + 'access_token=' + self.token
return url
+ def wait_for_limit_reset(self, headers):
+ reset = headers.get('X-RateLimit-Reset')
+ limit = headers.get('X-RateLimit-Limit')
+ reset = datetime.utcfromtimestamp(int(reset))
+ now = datetime.utcnow()
+ log.warn('Rate limit exceeded (%s requests/hour). '
+ 'Sleeping until %s UTC' % (limit, reset))
+ time.sleep((reset - now).total_seconds())
+
def urlopen(self, url, **kw):
- resp = super(GitHubProjectExtractor, self).urlopen(self.add_token(url), **kw)
+ try:
+ resp = super(GitHubProjectExtractor, self).urlopen(self.add_token(url), **kw)
+ except urllib2.HTTPError as e:
+ # GitHub will return 403 if rate limit exceeded.
+ # We're checking for limit on every request below, but we still
+ # can get 403 if other import task exceeds the limit before.
+ if e.code == 403 and e.info().get('X-RateLimit-Remaining') == '0':
+ self.wait_for_limit_reset(e.info())
+ return self.urlopen(url, **kw)
+ else:
+ raise e
remain = resp.info().get('X-RateLimit-Remaining')
if remain and int(remain) == 0:
- reset = resp.info().get('X-RateLimit-Reset')
- limit = resp.info().get('X-RateLimit-Limit')
- reset = datetime.utcfromtimestamp(int(reset))
- now = datetime.utcnow()
- log.warn('Rate limit exceeded (%s requests/hour). '
- 'Sleeping until %s UTC' % (limit, reset))
- time.sleep((reset - now).total_seconds())
- self.urlopen(url, **kw)
+ self.wait_for_limit_reset(resp.info())
+ return self.urlopen(url, **kw)
return resp
def get_next_page_url(self, link):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c07c836/ForgeImporters/forgeimporters/tests/github/test_extractor.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/github/test_extractor.py b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
index b3ad2f2..e6c96e3 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
@@ -16,8 +16,8 @@
# under the License.
import json
-from datetime import datetime
from unittest import TestCase
+import urllib2
from mock import patch, Mock
@@ -164,8 +164,7 @@ class TestGitHubProjectExtractor(TestCase):
response_limit_exceeded.info = lambda: limit_exceeded_headers
response_ok = StringIO('{}')
response_ok.info = lambda: {}
- results = [response_limit_exceeded, response_ok]
- urlopen.side_effect = lambda *a, **kw: results.pop(0)
+ urlopen.side_effect = [response_limit_exceeded, response_ok]
e = github.GitHubProjectExtractor('test_project')
e.get_page('fake')
self.assertEqual(sleep.call_count, 1)
@@ -175,8 +174,36 @@ class TestGitHubProjectExtractor(TestCase):
'Sleeping until 2013-10-25 09:32:02 UTC'
)
sleep.reset_mock(); urlopen.reset_mock(); log.warn.reset_mock()
- urlopen.side_effect = lambda *a, **kw: response_ok
+ response_ok = StringIO('{}')
+ response_ok.info = lambda: {}
+ urlopen.side_effect = [response_ok]
e.get_page('fake 2')
self.assertEqual(sleep.call_count, 0)
self.assertEqual(urlopen.call_count, 1)
self.assertEqual(log.warn.call_count, 0)
+
+ @patch('forgeimporters.base.h.urlopen')
+ @patch('forgeimporters.github.time.sleep')
+ @patch('forgeimporters.github.log')
+ def test_urlopen_rate_limit_403(self, log, sleep, urlopen):
+ '''Test that urlopen catches 403 which may happen if limit exceeded by another task'''
+ limit_exceeded_headers = {
+ 'X-RateLimit-Limit': '10',
+ 'X-RateLimit-Remaining': '0',
+ 'X-RateLimit-Reset': '1382693522',
+ }
+ def urlopen_side_effect(*a, **kw):
+ mock_resp = StringIO('{}')
+ mock_resp.info = lambda: {}
+ urlopen.side_effect = [mock_resp]
+ raise urllib2.HTTPError(
+ 'url', 403, 'msg', limit_exceeded_headers, StringIO('{}'))
+ urlopen.side_effect = urlopen_side_effect
+ e = github.GitHubProjectExtractor('test_project')
+ e.get_page('fake')
+ self.assertEqual(sleep.call_count, 1)
+ self.assertEqual(urlopen.call_count, 2)
+ log.warn.assert_called_once_with(
+ 'Rate limit exceeded (10 requests/hour). '
+ 'Sleeping until 2013-10-25 09:32:02 UTC'
+ )
[39/44] git commit: [#6656] ticket:437 Use token in github importers
Posted by jo...@apache.org.
[#6656] ticket:437 Use token in github importers
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0775036a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0775036a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0775036a
Branch: refs/heads/cj/6815
Commit: 0775036a41f7bc3e6616cbc09b7093d18bf16570
Parents: d1f23ad
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Oct 25 15:28:53 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 20:45:41 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/__init__.py | 2 +-
ForgeImporters/forgeimporters/github/code.py | 2 +-
ForgeImporters/forgeimporters/github/tasks.py | 2 +-
ForgeImporters/forgeimporters/github/tracker.py | 2 +-
ForgeImporters/forgeimporters/github/wiki.py | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0775036a/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index a92f4a1..fb34e6b 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -46,7 +46,7 @@ class GitHubProjectExtractor(base.ProjectExtractor):
self.token = None
user = kw.pop('user', None)
if user:
- self.token = user.get_tool_data('GitHubProjectExtractor', 'token')
+ self.token = user.get_tool_data('GitHubProjectImport', 'token')
super(GitHubProjectExtractor, self).__init__(*args, **kw)
def add_token(self, url):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0775036a/ForgeImporters/forgeimporters/github/code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/code.py b/ForgeImporters/forgeimporters/github/code.py
index 1017eba..4ce2183 100644
--- a/ForgeImporters/forgeimporters/github/code.py
+++ b/ForgeImporters/forgeimporters/github/code.py
@@ -92,7 +92,7 @@ class GitHubRepoImporter(ToolImporter):
"""
project_name = "%s/%s" % (user_name, project_name)
- extractor = GitHubProjectExtractor(project_name)
+ extractor = GitHubProjectExtractor(project_name, user=user)
repo_url = extractor.get_repo_url()
app = project.install_app(
"Git",
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0775036a/ForgeImporters/forgeimporters/github/tasks.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tasks.py b/ForgeImporters/forgeimporters/github/tasks.py
index 9abdb3d..d74a9cd 100644
--- a/ForgeImporters/forgeimporters/github/tasks.py
+++ b/ForgeImporters/forgeimporters/github/tasks.py
@@ -31,7 +31,7 @@ def import_project_info(project_name):
from forgeimporters.github.project import GitHubProjectImporter
importer = GitHubProjectImporter(None)
with ImportErrorHandler(importer, project_name, c.project) as handler:
- extractor = GitHubProjectExtractor(project_name)
+ extractor = GitHubProjectExtractor(project_name, user=c.user)
c.project.summary = extractor.get_summary()
c.project.external_homepage = extractor.get_homepage()
ThreadLocalORMSession.flush_all()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0775036a/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index 5e3c134..288379b 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -114,7 +114,7 @@ class GitHubTrackerImporter(ToolImporter):
self.github_markdown_converter = GitHubMarkdownConverter(
kw['user_name'], project_name)
ThreadLocalORMSession.flush_all()
- extractor = GitHubProjectExtractor(project_name)
+ extractor = GitHubProjectExtractor(project_name, user=user)
try:
M.session.artifact_orm_session._get().skip_mod_date = True
with h.push_config(c, user=M.User.anonymous(), app=app):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0775036a/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 8fae1b1..ce3214c 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -139,7 +139,7 @@ class GitHubWikiImporter(ToolImporter):
"""
project_name = "%s/%s" % (user_name, project_name)
- extractor = GitHubProjectExtractor(project_name)
+ extractor = GitHubProjectExtractor(project_name, user=user)
if not extractor.has_wiki():
return
[42/44] git commit: [#6656] Updated requests version and added
oauthlib to match requests-oauthlib dependencies
Posted by jo...@apache.org.
[#6656] Updated requests version and added oauthlib to match requests-oauthlib dependencies
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c1fc7144
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c1fc7144
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c1fc7144
Branch: refs/heads/cj/6815
Commit: c1fc7144e9beb6c1b63434a76c2f01d5b7537384
Parents: 5f43489
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Nov 13 21:37:12 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 21:37:12 2013 +0000
----------------------------------------------------------------------
requirements-common.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c1fc7144/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index 685f437..a8747b4 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -38,7 +38,8 @@ python-magic==0.4.3
python-openid==2.2.5
python-oembed==0.2.1
pytidylib==0.2.1
-requests==1.2.3
+requests==2.0.0
+oauthlib==0.4.2
requests-oauthlib==0.4.0
# for taskd proc name switching
setproctitle==1.1.7
[19/44] git commit: [#6622] ticket:435 Fix code block regex
Posted by jo...@apache.org.
[#6622] ticket:435 Fix code block regex
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/88365c69
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/88365c69
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/88365c69
Branch: refs/heads/cj/6815
Commit: 88365c69c23f5351d944f39e0c3859bd1cfe84c7
Parents: d7ee191
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 16:33:15 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:56 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 20 +++++++++++++++++++-
ForgeImporters/forgeimporters/github/utils.py | 2 +-
2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88365c69/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 3ce8d29..e3ba75c 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -76,6 +76,24 @@ class TestGitHubMarkdownConverter(object):
def test_convert_code_blocks(self):
text = u'''```python
print "Hello!"
+```
+
+Two code blocks here!
+
+```
+for (var i = 0; i < a.length; i++) {
+ console.log(i);
+}
```'''
- result = u'~~~~\nprint "Hello!"\n~~~~'
+ result = u'''~~~~
+print "Hello!"
+~~~~
+
+Two code blocks here!
+
+~~~~
+for (var i = 0; i < a.length; i++) {
+ console.log(i);
+}
+~~~~'''
assert_equal(self.conv.convert(text).strip(), result)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88365c69/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index da50c2d..f00140d 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -30,7 +30,7 @@ class GitHubMarkdownConverter(object):
_re = re.compile(r'~~(.*)~~',)
text = _re.sub(self._convert_strikethrough, text)
- _re = re.compile(r'```\w*(.*)```', re.DOTALL)
+ _re = re.compile(r'```\w*(.*?)```', re.DOTALL)
text = _re.sub(self._convert_codeblock, text)
return text
[12/44] git commit: [#6622] ticket:435 Fix sha regex
Posted by jo...@apache.org.
[#6622] ticket:435 Fix sha regex
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/ba536053
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ba536053
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ba536053
Branch: refs/heads/cj/6815
Commit: ba536053652354679c45fc2e79c0cf678576aa92
Parents: b6f29e9
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 15:07:03 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:55 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 75 +++++++++++++++-----
ForgeImporters/forgeimporters/github/utils.py | 49 +++++++------
2 files changed, 80 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ba536053/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 8711312..44d186a 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -6,34 +6,71 @@ from forgeimporters.github.utils import GitHubMarkdownConverter
class TestGitHubMarkdownConverter(object):
def setUp(self):
- self.conv = GitHubMarkdownConverter
+ self.conv = GitHubMarkdownConverter('user', 'project', 'p', 'mount')
- def test_convert_sha_github_markup(self):
- text = 'SHA: 16c999e8c71134401a78d4d46435517b2271d6ac'
+ def test_convert_sha(self):
+ text = '16c999e8c71134401a78d4d46435517b2271d6ac'
result = self.conv.convert(text)
- assert_equal(result, 'SHA: [16c999]')
+ assert_equal(result, '[16c999]')
- def test_convert_user_sha_github_markup(self):
- text = 'User@SHA: mojombo@16c999e8c71134401a78d4d46435517b2271d6ac'
+ text = 'some context 16c999e8c71134401a78d4d46435517b2271d6ac '
result = self.conv.convert(text)
- assert_equal(result, 'User@SHA:[16c999]')
+ assert_equal(result, 'some context [16c999] ')
- def test_convert_user_repo_sha_github_markup(self):
- text = 'User/Repository@SHA: mojombo/github-flavored-markdown@16c999e8c71134401a78d4d46435517b2271d6ac'
+ def test_convert_user_sha(self):
+ text = 'user@16c999e8c71134401a78d4d46435517b2271d6ac'
result = self.conv.convert(text)
- assert_equal(result, 'User/Repository@SHA: [16c999]')
+ assert_equal(result, '[16c999]')
- def test_convert_ticket_github_markup(self):
- text = 'Ticket: #1'
+ # Not an owner of current project
+ text = 'another-user@16c999e8c71134401a78d4d46435517b2271d6ac'
result = self.conv.convert(text)
- assert_equal(result, 'Ticket: [#1]')
+ assert_equal(result, text)
- def test_convert_username_ticket_github_markup(self):
- text = 'User#Num: user#1'
+ def test_convert_user_repo_sha(self):
+ text = 'user/project@16c999e8c71134401a78d4d46435517b2271d6ac'
result = self.conv.convert(text)
- assert_equal(result, 'User#Num: [#1]')
+ assert_equal(result, '[p:mount:16c999e8c71134401a78d4d46435517b2271d6ac]')
- def test_convert_username_repo_ticket_github_markup(self):
- text = 'User/Repository#Num: user/repo#1'
+ # Not a current project
+ text = 'user/p@16c999e8c71134401a78d4d46435517b2271d6ac'
result = self.conv.convert(text)
- assert_equal(result, 'User/Repository#Num: [#1]')
+ assert_equal(result, '[user/project@16c999e8c71134401a78d4d46435517b2271d6ac]'
+ '(https://github.com/u/p/commit/16c999e8c71134401a78d4d46435517b2271d6ac)')
+
+ def test_convert_ticket(self):
+ text = 'Ticket #1'
+ result = self.conv.convert(text)
+ assert_equal(result, 'Ticket [#1]')
+
+ def test_convert_username_ticket(self):
+ text = 'user#1'
+ result = self.conv.convert(text)
+ assert_equal(result, '[#1]')
+
+ # Not an owner of current project
+ text = 'another-user#1'
+ result = self.conv.convert(text)
+ assert_equal(result, 'another-user#1')
+
+ def test_convert_username_repo_ticket(self):
+ text = 'user/project#1'
+ result = self.conv.convert(text)
+ assert_equal(result, '[p:mount:#1]')
+
+ # Not a current project
+ text = 'user/p#1'
+ result = self.conv.convert(text)
+ assert_equal(result, '[user/project@16c999e8c71134401a78d4d46435517b2271d6ac]'
+ '(https://github.com/u/p/issues/1)')
+
+ def test_convert_strikethrough(self):
+ text = '~~mistake~~'
+ assert_equal(self.conv.convert(text), '<s>mistake</s>')
+
+ def test_convert_code_blocks(self):
+ text = u'''```python
+print "Hello!"
+```'''
+ result = u'~~~~\nprint "Hello!"\n~~~~'
+ assert_equal(self.conv.convert(text).strip(), result)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ba536053/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index ab66157..282e312 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -3,45 +3,44 @@ import re
class GitHubMarkdownConverter(object):
- @classmethod
- def convert(cls, text):
- _re = re.compile('\S*(#\d+)')
- text = _re.sub(cls._convert_ticket, text)
+ def __init__(self, gh_user, gh_project, project, mount_point):
+ self.gh_project = '%s/%s' % (gh_project, gh_user)
+ self.project = '%s:%s' % (project, mount_point)
- _re = re.compile('\S*/\S*@(\w{40})')
- text = _re.sub(cls._convert_user_repo_sha, text)
+ def convert(self, text):
+ _re = re.compile('\S+\s+(#\d+)')
+ text = _re.sub(self._convert_ticket, text)
- _re = re.compile('\s\S*@(\w{40})')
- text = _re.sub(cls._convert_user_sha, text)
+ _re = re.compile('\S*/\S*@([0-9a-f]{40})')
+ text = _re.sub(self._convert_user_repo_sha, text)
+
+ _re = re.compile('\s\S*@([0-9a-f]{40})')
+ text = _re.sub(self._convert_user_sha, text)
+
+ _re = re.compile('(\s|^)([0-9a-f]{40})(\s|$)')
+ text = _re.sub(self._convert_sha, text)
- _re = re.compile(': (\w{40})')
- text = _re.sub(cls._convert_sha, text)
_re = re.compile('~~(.*)~~',)
- text = _re.sub(cls._convert_strikethrough, text)
+ text = _re.sub(self._convert_strikethrough, text)
+
_re = re.compile(r'```\w*(.*)```', re.DOTALL)
- text = _re.sub(cls._convert_codeblock, text)
+ text = _re.sub(self._convert_codeblock, text)
return text
- @classmethod
- def _convert_sha(cls, match):
- return ': [%s]' % match.group(1)[:6]
+ def _convert_sha(self, match):
+ return '%s[%s]%s' % (match.group(1), match.group(2)[:6], match.group(3))
- @classmethod
- def _convert_ticket(cls, match):
+ def _convert_ticket(self, match):
return '[%s]' % match.group(1)
- @classmethod
- def _convert_user_sha(cls, match):
+ def _convert_user_sha(self, match):
return '[%s]' % (match.group(1)[:6])
- @classmethod
- def _convert_user_repo_sha(cls, match):
+ def _convert_user_repo_sha(self, match):
return '[%s]' % (match.group(1)[:6])
- @classmethod
- def _convert_strikethrough(cls, match):
+ def _convert_strikethrough(self, match):
return '<s>%s</s>' % match.group(1)
- @classmethod
- def _convert_codeblock(cls, match):
+ def _convert_codeblock(self, match):
return '~~~~%s~~~~'% match.group(1)
[09/44] git commit: [#6622] ticket:435 Fix ticket regex
Posted by jo...@apache.org.
[#6622] ticket:435 Fix ticket regex
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/9e9b826f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9e9b826f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9e9b826f
Branch: refs/heads/cj/6815
Commit: 9e9b826f9ba2389f4de23166aeaaca717ae91415
Parents: ba53605
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 15:10:18 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:55 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/tests/test_utils.py | 6 ++++++
ForgeImporters/forgeimporters/github/utils.py | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9e9b826f/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 44d186a..0b86623 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -43,6 +43,12 @@ class TestGitHubMarkdownConverter(object):
result = self.conv.convert(text)
assert_equal(result, 'Ticket [#1]')
+ # github treats '#' in the begining as a header
+ text = '#1'
+ assert_equal(self.conv.convert(text), '#1')
+ text = ' #1'
+ assert_equal(self.conv.convert(text), ' #1')
+
def test_convert_username_ticket(self):
text = 'user#1'
result = self.conv.convert(text)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9e9b826f/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index 282e312..f74f8eb 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -8,7 +8,7 @@ class GitHubMarkdownConverter(object):
self.project = '%s:%s' % (project, mount_point)
def convert(self, text):
- _re = re.compile('\S+\s+(#\d+)')
+ _re = re.compile('(\S+\s+)(#\d+)')
text = _re.sub(self._convert_ticket, text)
_re = re.compile('\S*/\S*@([0-9a-f]{40})')
@@ -31,7 +31,7 @@ class GitHubMarkdownConverter(object):
return '%s[%s]%s' % (match.group(1), match.group(2)[:6], match.group(3))
def _convert_ticket(self, match):
- return '[%s]' % match.group(1)
+ return '%s[%s]' % match.groups()
def _convert_user_sha(self, match):
return '[%s]' % (match.group(1)[:6])
[03/44] git commit: [#6860] Add CC to smtp envelope addrs
Posted by jo...@apache.org.
[#6860] Add CC to smtp envelope addrs
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f1c92401
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f1c92401
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f1c92401
Branch: refs/heads/cj/6815
Commit: f1c92401cb32d79afe22509175c70f9da8320053
Parents: 35eeee5
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Fri Nov 8 21:00:02 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Nov 8 21:00:02 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/mail_util.py | 1 +
Allura/allura/tests/test_tasks.py | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f1c92401/Allura/allura/lib/mail_util.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/mail_util.py b/Allura/allura/lib/mail_util.py
index ef0cc71..78fcc78 100644
--- a/Allura/allura/lib/mail_util.py
+++ b/Allura/allura/lib/mail_util.py
@@ -217,6 +217,7 @@ class SMTPClient(object):
message['Sender'] = AddrHeader(sender)
if cc:
message['CC'] = AddrHeader(cc)
+ addrs.append(cc)
if in_reply_to:
if not isinstance(in_reply_to, basestring):
raise TypeError('Only strings are supported now, not lists')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f1c92401/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 23aab99..13c6f7f 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -344,6 +344,22 @@ class TestMailTasks(unittest.TestCase):
assert_in('From: "Test Admin" <te...@users.localhost>', body)
assert_in('References: <ref>', body)
+ def test_cc(self):
+ c.user = M.User.by_username('test-admin')
+ with mock.patch.object(mail_tasks.smtp_client, '_client') as _client:
+ mail_tasks.sendsimplemail(
+ fromaddr=str(c.user._id),
+ toaddr='test@mail.com',
+ text=u'This is a test',
+ reply_to=u'noreply@sf.net',
+ subject=u'Test subject',
+ cc=u'someone@example.com',
+ message_id=h.gen_message_id())
+ assert_equal(_client.sendmail.call_count, 1)
+ return_path, rcpts, body = _client.sendmail.call_args[0]
+ assert_in('CC: someone@example.com', body)
+ assert_in('someone@example.com', rcpts)
+
@td.with_wiki
def test_receive_email_ok(self):
c.user = M.User.by_username('test-admin')
[04/44] git commit: [#6844] Fixed GC project icons not saving
Posted by jo...@apache.org.
[#6844] Fixed GC project icons not saving
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/a4e46b7a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a4e46b7a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a4e46b7a
Branch: refs/heads/cj/6815
Commit: a4e46b7ab6ee430e9d96a8546b0e83bbd0289ae5
Parents: f1c9240
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Nov 8 20:29:04 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 11 20:45:05 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/base.py | 9 +++++++++
ForgeImporters/forgeimporters/tests/test_base.py | 10 +++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a4e46b7a/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 97f7c92..4f05156 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -513,6 +513,7 @@ class ImportAdminExtension(AdminExtension):
def stringio_parser(page):
return {
+ 'content-type': page.info()['content-type'],
'data': StringIO(page.read()),
}
@@ -521,7 +522,15 @@ class File(object):
extractor = ProjectExtractor(None, url, parser=stringio_parser)
self.url = url
self.filename = filename or os.path.basename(urlparse(url).path)
+ # try to get the mime-type from the filename first, because
+ # some files (e.g., attachements) may have the Content-Type header
+ # forced to encourage the UA to download / save the file
self.type = guess_mime_type(self.filename)
+ if self.type == 'application/octet-stream':
+ # however, if that fails, fall back to the given mime-type,
+ # as some files (e.g., project icons) might have no file
+ # extension but return a valid Content-Type header
+ self.type = extractor.page['content-type']
self.file = extractor.page['data']
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a4e46b7a/ForgeImporters/forgeimporters/tests/test_base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/test_base.py b/ForgeImporters/forgeimporters/tests/test_base.py
index b1b2e63..ade7b7a 100644
--- a/ForgeImporters/forgeimporters/tests/test_base.py
+++ b/ForgeImporters/forgeimporters/tests/test_base.py
@@ -347,10 +347,14 @@ def test_save_importer_upload(giup, os):
class TestFile(object):
- @mock.patch.object(base, 'ProjectExtractor', mock.MagicMock)
- def test_type(self):
+ @mock.patch.object(base, 'ProjectExtractor')
+ def test_type(self, PE):
+ PE().page = {
+ 'content-type': 'image/png',
+ 'data': 'data',
+ }
f = base.File('http://example.com/barbaz.jpg')
assert_equal(f.type, 'image/jpeg')
f = base.File('http://example.com/barbaz')
- assert_equal(f.type, 'application/octet-stream')
+ assert_equal(f.type, 'image/png')
[25/44] git commit: [#6622] ticket:494 Fix test failing due to new
ticket regex
Posted by jo...@apache.org.
[#6622] ticket:494 Fix test failing due to new ticket regex
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/9efb6896
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9efb6896
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9efb6896
Branch: refs/heads/cj/6815
Commit: 9efb68969c6c12f558868529742af8595f064894
Parents: 05de134
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 13 11:33:57 2013 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:57 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/tests/test_wiki.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9efb6896/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 e0c83bb..b9b18bd 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -324,7 +324,7 @@ Our website is <http://sf.net>.
ticket [#1]
-#1 header
+[#1] header
sha [aaaaaa]'''
assert_equal(f(source, 'test.md').strip(), result)
[35/44] git commit: [#6656] ticket:437 Use OAuth token for github api
calls
Posted by jo...@apache.org.
[#6656] ticket:437 Use OAuth token for github api calls
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d396c9e6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d396c9e6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d396c9e6
Branch: refs/heads/cj/6815
Commit: d396c9e6db9e45c07465d5d73375068787c3c594
Parents: 2c6339a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Oct 25 11:15:52 2013 +0300
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 20:43:45 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/__init__.py | 19 +++++++++++++--
.../tests/github/test_extractor.py | 25 +++++++++++++++++++-
2 files changed, 41 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d396c9e6/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index 2963067..5726326 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -18,8 +18,6 @@
import re
import logging
import json
-import urllib
-import urllib2
from forgeimporters import base
@@ -36,6 +34,23 @@ class GitHubProjectExtractor(base.ProjectExtractor):
SUPPORTED_ISSUE_EVENTS = ('closed', 'reopened', 'assigned')
NEXT_PAGE_URL_RE = re.compile(r'<([^>]*)>; rel="next"')
+ def __init__(self, *args, **kw):
+ self.token = None
+ user = kw.pop('user', None)
+ if user:
+ self.token = user.get_tool_data('GitHubProjectExtractor', 'token')
+ super(GitHubProjectExtractor, self).__init__(*args, **kw)
+
+ def add_token(self, url):
+ if self.token:
+ glue = '&' if '?' in url else '?'
+ url += glue + 'access_token=' + self.token
+ return url
+
+ def urlopen(self, url, **kw):
+ url = self.add_token(url)
+ return super(GitHubProjectExtractor, self).urlopen(url, **kw)
+
def get_next_page_url(self, link):
if not link:
return
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d396c9e6/ForgeImporters/forgeimporters/tests/github/test_extractor.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/github/test_extractor.py b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
index 11601a5..a26438a 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
@@ -18,6 +18,8 @@
import json
from unittest import TestCase
+from mock import patch, Mock
+
from ... import github
# Can't use cStringIO here, because we cannot set attributes or subclass it,
@@ -84,6 +86,7 @@ class TestGitHubProjectExtractor(TestCase):
def setUp(self):
self.extractor = github.GitHubProjectExtractor('test_project')
self.extractor.urlopen = self.mocked_urlopen
+
def test_get_next_page_url(self):
self.assertIsNone(self.extractor.get_next_page_url(None))
self.assertIsNone(self.extractor.get_next_page_url(''))
@@ -97,7 +100,7 @@ class TestGitHubProjectExtractor(TestCase):
link = '<https://api.github.com/repositories/8560576/issues?state=open&page=1>; rel="prev"'
self.assertIsNone(self.extractor.get_next_page_url(link))
-
+
def test_get_summary(self):
self.assertEqual(self.extractor.get_summary(), 'project description')
@@ -126,3 +129,23 @@ class TestGitHubProjectExtractor(TestCase):
def test_get_wiki_url(self):
self.assertEqual(self.extractor.get_page_url('wiki_url'), 'https://github.com/test_project.wiki')
+
+ @patch('forgeimporters.base.h.urlopen')
+ def test_urlopen(self, urlopen):
+ e = github.GitHubProjectExtractor('test_project')
+ url = 'https://github.com/u/p/'
+ e.urlopen(url)
+ request = urlopen.call_args[0][0]
+ self.assertEqual(request.get_full_url(), url)
+
+ user = Mock()
+ user.get_tool_data.return_value = 'abc'
+ e = github.GitHubProjectExtractor('test_project', user=user)
+ e.urlopen(url)
+ request = urlopen.call_args[0][0]
+ self.assertEqual(request.get_full_url(), url + '?access_token=abc')
+
+ url = 'https://github.com/u/p/?p=1'
+ e.urlopen(url)
+ request = urlopen.call_args[0][0]
+ self.assertEqual(request.get_full_url(), url + '&access_token=abc')
[07/44] git commit: [#6622] ticket:435 Fix user@sha regex
Posted by jo...@apache.org.
[#6622] ticket:435 Fix user@sha regex
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f0e61173
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f0e61173
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f0e61173
Branch: refs/heads/cj/6815
Commit: f0e61173294de836ef0b59f6954806f34e63cd21
Parents: 3c12029
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 16:16:29 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:55 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/utils.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f0e61173/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index 6d22266..defe391 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -15,7 +15,7 @@ class GitHubMarkdownConverter(object):
_re = re.compile(r'(\s|^)(.+)/(.+)@([0-9a-f]{40})(\s|$)')
text = _re.sub(self._convert_user_repo_sha, text)
- _re = re.compile(r'\s\S*@([0-9a-f]{40})')
+ _re = re.compile(r'(\s|^)(.+)@([0-9a-f]{40})(\s|$)')
text = _re.sub(self._convert_user_sha, text)
_re = re.compile(r'(\s|^)([0-9a-f]{40})(\s|$)')
@@ -38,7 +38,11 @@ class GitHubMarkdownConverter(object):
return '%s[%s]' % m.groups()
def _convert_user_sha(self, m):
- return '[%s]' % (m.group(1)[:6])
+ user = m.group(2)
+ sha = m.group(3)
+ if self.gh_project.startswith(user + '/'):
+ return '%s[%s]%s' % (m.group(1), sha[:6], m.group(4))
+ return m.group(0)
def _convert_user_repo_sha(self, m):
project = '%s/%s' % (m.group(2), m.group(3))
[44/44] git commit: [#6815] Leave off "Originally owned by: nobody"
from imported unowned Allura tickets
Posted by jo...@apache.org.
[#6815] Leave off "Originally owned by: nobody" from imported unowned Allura tickets
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/cce5b5cd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/cce5b5cd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/cce5b5cd
Branch: refs/heads/cj/6815
Commit: cce5b5cd3acf299b8e166b659a492f558b63ab93
Parents: c330602
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Nov 13 22:57:07 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 22:57:07 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/forge/tracker.py | 2 +-
ForgeImporters/forgeimporters/tests/forge/test_tracker.py | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cce5b5cd/ForgeImporters/forgeimporters/forge/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/forge/tracker.py b/ForgeImporters/forgeimporters/forge/tracker.py
index c758651..0fe3fea 100644
--- a/ForgeImporters/forgeimporters/forge/tracker.py
+++ b/ForgeImporters/forgeimporters/forge/tracker.py
@@ -184,7 +184,7 @@ class ForgeTrackerImporter(ToolImporter):
return user
def annotate(self, text, user, username, label=''):
- if username and user.is_anonymous():
+ if username and user.is_anonymous() and username != 'nobody':
return '*Originally%s by:* %s\n\n%s' % (label, username, text)
return text
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cce5b5cd/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/forge/test_tracker.py b/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
index 0b8fa05..85f4650 100644
--- a/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
@@ -236,6 +236,7 @@ class TestTrackerImporter(TestCase):
self.assertEqual(importer.annotate('foo', user, 'bar'), 'foo')
user.is_anonymous.return_value = True
self.assertEqual(importer.annotate('foo', user, 'bar'), '*Originally by:* bar\n\nfoo')
+ self.assertEqual(importer.annotate('foo', user, 'nobody'), 'foo')
self.assertEqual(importer.annotate('foo', user, None), 'foo')
@mock.patch.object(tracker, 'File')
[08/44] git commit: [#6622] ticket:435 Fix user/repo@sha regex
Posted by jo...@apache.org.
[#6622] ticket:435 Fix user/repo@sha regex
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/3c12029e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3c12029e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3c12029e
Branch: refs/heads/cj/6815
Commit: 3c12029ef3e3007ee37db06633d3d1ffc5a78164
Parents: 9e9b826
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 15:43:10 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:55 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 9 ++--
ForgeImporters/forgeimporters/github/utils.py | 48 ++++++++++++--------
2 files changed, 34 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c12029e/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 0b86623..a0dfbcc 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -30,13 +30,13 @@ class TestGitHubMarkdownConverter(object):
def test_convert_user_repo_sha(self):
text = 'user/project@16c999e8c71134401a78d4d46435517b2271d6ac'
result = self.conv.convert(text)
- assert_equal(result, '[p:mount:16c999e8c71134401a78d4d46435517b2271d6ac]')
+ assert_equal(result, '[p:mount:16c999]')
# Not a current project
text = 'user/p@16c999e8c71134401a78d4d46435517b2271d6ac'
result = self.conv.convert(text)
- assert_equal(result, '[user/project@16c999e8c71134401a78d4d46435517b2271d6ac]'
- '(https://github.com/u/p/commit/16c999e8c71134401a78d4d46435517b2271d6ac)')
+ assert_equal(result, '[user/p@16c999]'
+ '(https://github.com/user/p/commit/16c999e8c71134401a78d4d46435517b2271d6ac)')
def test_convert_ticket(self):
text = 'Ticket #1'
@@ -67,8 +67,7 @@ class TestGitHubMarkdownConverter(object):
# Not a current project
text = 'user/p#1'
result = self.conv.convert(text)
- assert_equal(result, '[user/project@16c999e8c71134401a78d4d46435517b2271d6ac]'
- '(https://github.com/u/p/issues/1)')
+ assert_equal(result, '[user/p#1](https://github.com/u/p/issues/1)')
def test_convert_strikethrough(self):
text = '~~mistake~~'
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c12029e/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index f74f8eb..6d22266 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -4,43 +4,55 @@ import re
class GitHubMarkdownConverter(object):
def __init__(self, gh_user, gh_project, project, mount_point):
- self.gh_project = '%s/%s' % (gh_project, gh_user)
+ 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):
- _re = re.compile('(\S+\s+)(#\d+)')
+ _re = re.compile(r'(\S+\s+)(#\d+)')
text = _re.sub(self._convert_ticket, text)
- _re = re.compile('\S*/\S*@([0-9a-f]{40})')
+ _re = re.compile(r'(\s|^)(.+)/(.+)@([0-9a-f]{40})(\s|$)')
text = _re.sub(self._convert_user_repo_sha, text)
- _re = re.compile('\s\S*@([0-9a-f]{40})')
+ _re = re.compile(r'\s\S*@([0-9a-f]{40})')
text = _re.sub(self._convert_user_sha, text)
- _re = re.compile('(\s|^)([0-9a-f]{40})(\s|$)')
+ _re = re.compile(r'(\s|^)([0-9a-f]{40})(\s|$)')
text = _re.sub(self._convert_sha, text)
- _re = re.compile('~~(.*)~~',)
+ _re = re.compile(r'~~(.*)~~',)
text = _re.sub(self._convert_strikethrough, text)
_re = re.compile(r'```\w*(.*)```', re.DOTALL)
text = _re.sub(self._convert_codeblock, text)
return text
- def _convert_sha(self, match):
- return '%s[%s]%s' % (match.group(1), match.group(2)[:6], match.group(3))
+ def _gh_commit_url(self, project, sha, title):
+ return u'[%s](%s)' % (title, self.gh_base_url + project + '/commit/' + sha)
- def _convert_ticket(self, match):
- return '%s[%s]' % match.groups()
+ def _convert_sha(self, m):
+ return '%s[%s]%s' % (m.group(1), m.group(2)[:6], m.group(3))
- def _convert_user_sha(self, match):
- return '[%s]' % (match.group(1)[:6])
+ def _convert_ticket(self, m):
+ return '%s[%s]' % m.groups()
- def _convert_user_repo_sha(self, match):
- return '[%s]' % (match.group(1)[:6])
+ def _convert_user_sha(self, m):
+ return '[%s]' % (m.group(1)[:6])
- def _convert_strikethrough(self, match):
- return '<s>%s</s>' % match.group(1)
+ def _convert_user_repo_sha(self, m):
+ 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))
+ title = project + '@' + sha[:6]
+ return ''.join([m.group(1),
+ self._gh_commit_url(project, sha, title),
+ m.group(5)])
- def _convert_codeblock(self, match):
- return '~~~~%s~~~~'% match.group(1)
+ def _convert_strikethrough(self, m):
+ return '<s>%s</s>' % m.group(1)
+
+ def _convert_codeblock(self, m):
+ return '~~~~%s~~~~'% m.group(1)
[17/44] git commit: [#6622] ticket:435 convert user/project
references into shortlinks
Posted by jo...@apache.org.
[#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/cj/6815
Commit: d2d337b0f74c9ace05f1c9dbbda2e2de52152f41
Parents: 3cda147
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 17:20:59 2013 +0300
Committer: Dave Brondsema <db...@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,
[32/44] git commit: [#6852] ticket:476 added maximize button for
tracker pages
Posted by jo...@apache.org.
[#6852] ticket:476 added maximize button for tracker pages
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/bf4195f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/bf4195f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/bf4195f0
Branch: refs/heads/cj/6815
Commit: bf4195f01c7238cbec01f9f0eb13572e5e5c3196
Parents: ff04c8b
Author: Yaroslav Sokolovsky <ya...@gmail.com>
Authored: Thu Nov 7 14:52:02 2013 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 19:21:58 2013 +0000
----------------------------------------------------------------------
Allura/allura/nf/allura/css/site_style.css | 5 +++++
ForgeTracker/forgetracker/templates/tracker/index.html | 2 ++
ForgeTracker/forgetracker/templates/tracker/milestone.html | 2 ++
ForgeTracker/forgetracker/templates/tracker/search.html | 2 ++
4 files changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bf4195f0/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 700b3ac..3c132ad 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -3263,6 +3263,11 @@ ul.dropdown ul li a:hover {
width: 100%;
}
+.content-maximized #content_base .ticket-list
+{
+ width: 99%;
+}
+
.content-maximized #content_base .diffbrowser {
width: auto;
}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bf4195f0/ForgeTracker/forgetracker/templates/tracker/index.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/index.html b/ForgeTracker/forgetracker/templates/tracker/index.html
index 7b3ad36..a9f803e 100644
--- a/ForgeTracker/forgetracker/templates/tracker/index.html
+++ b/ForgeTracker/forgetracker/templates/tracker/index.html
@@ -17,6 +17,7 @@
under the License.
-#}
{% extends g.theme.master %}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
{% do g.register_app_css('css/tracker.css') %}
{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}}{% endblock %}
@@ -29,6 +30,7 @@
{% block header %}{{c.app.config.options.mount_label}}{% endblock %}
{% block actions %}
+ {{ lib.maximize_content_button() }}
<a href="{{c.app.url}}feed.rss" title="Follow"><b data-icon="{{g.icons['feed'].char}}" class="ico {{g.icons['feed'].css}}"></b></a>
{% if c.user and c.user != c.user.anonymous() %}
{{c.subscribe_form.display(value=subscribed, action='subscribe', style='icon')}}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bf4195f0/ForgeTracker/forgetracker/templates/tracker/milestone.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/milestone.html b/ForgeTracker/forgetracker/templates/tracker/milestone.html
index 7c1cd00..e9e6c35 100644
--- a/ForgeTracker/forgetracker/templates/tracker/milestone.html
+++ b/ForgeTracker/forgetracker/templates/tracker/milestone.html
@@ -17,6 +17,7 @@
under the License.
-#}
{% extends g.theme.master %}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
{% do g.register_app_css('css/tracker.css') %}
@@ -25,6 +26,7 @@
{% block header %}{{field.label}} {{milestone.name}}{% endblock %}
{% block actions %}
+{{ lib.maximize_content_button() }}
{% if allow_edit %}
<a href="{{tg.url(c.app.url+'edit/', dict(q=q, limit=limit, sort=url_sort, page=page))}}" title="Bulk Edit"><b data-icon="{{g.icons['pencil'].char}}" class="ico {{g.icons['pencil'].css}}"></b></a>
{% endif %}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bf4195f0/ForgeTracker/forgetracker/templates/tracker/search.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/search.html b/ForgeTracker/forgetracker/templates/tracker/search.html
index ba9ece6..c355f47 100644
--- a/ForgeTracker/forgetracker/templates/tracker/search.html
+++ b/ForgeTracker/forgetracker/templates/tracker/search.html
@@ -17,6 +17,7 @@
under the License.
-#}
{% extends g.theme.master %}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
{% do g.register_app_css('css/tracker.css') %}
{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Search{% endblock %}
@@ -29,6 +30,7 @@
{% endblock %}
{% block actions %}
+ {{ lib.maximize_content_button() }}
<a href="{{tg.url(c.app.url+'search_feed/', dict(q=q, limit=limit, sort=sort))}}" title="Feed"><b data-icon="{{g.icons['feed'].char}}" class="ico {{g.icons['feed'].css}}"></b></a>
{% if allow_edit and count != 0 %}
<a href="{{tg.url(c.app.url+'edit/', dict(q=q, limit=limit, sort=sort, page=page))}}" title="Bulk Edit"><b data-icon="{{g.icons['pencil'].char}}" class="ico {{g.icons['pencil'].css}}"></b></a>
[23/44] git commit: [#6622] ticket:469 not handling inline blocks,
fixed parser
Posted by jo...@apache.org.
[#6622] ticket:469 not handling inline blocks, fixed parser
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/11e26216
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/11e26216
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/11e26216
Branch: refs/heads/cj/6815
Commit: 11e262165802abb0506ceb85750d88a120384f7a
Parents: ad1f2c3
Author: coldmind <so...@yandex.ru>
Authored: Fri Nov 8 13:49:11 2013 +0200
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:57 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 13 ++------
.../forgeimporters/github/tests/test_wiki.py | 5 ---
ForgeImporters/forgeimporters/github/utils.py | 32 +++++++++++---------
.../forgeimporters/tests/github/test_tracker.py | 11 ++-----
4 files changed, 22 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/11e26216/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 cc02e6b..f426d6b 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -85,22 +85,13 @@ for (var i = 0; i < a.length; i++) {
console.log(i);
}
```'''
- result = u'''<br>
-
- :::python
+ result = u''':::python
print "Hello!"
-<br>
-
-
Two code blocks here!
-
-<br>
-
for (var i = 0; i < a.length; i++) {
console.log(i);
- }
+ }'''
-<br>'''
assert_equal(self.conv.convert(text).strip(), result)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/11e26216/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 ee37c38..e0c83bb 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -319,14 +319,9 @@ Our website is <http://sf.net>.
[[Escaped Tag]]
-<br>
-
:::python
codeblock
-<br>
-
-
ticket [#1]
#1 header
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/11e26216/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index 5d64666..d509aa7 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -19,14 +19,9 @@ class GitHubMarkdownConverter(object):
nextline = False
for p in self.code_patterns:
if line.lstrip().startswith(p):
- # this is extreme, but due to display bugs
- # it's necessary
- new_lines.append('\n<br>\n')
-
if p == '```':
- _re = re.compile(r'\```(.*)')
- syntax = _re.findall(line)[0]
- if syntax and not syntax.isspace():
+ syntax = line.lstrip().lstrip('`').strip()
+ if syntax:
new_lines.append(self._codeblock_syntax(syntax))
in_block = not in_block
nextline = True
@@ -37,9 +32,22 @@ class GitHubMarkdownConverter(object):
if in_block:
new_lines.append(self._handle_code(line))
else:
- if line.lstrip().startswith(' '):
+ _re = re.compile(r'`\s*(.*?)`')
+ inline_matches = _re.findall(line)
+
+ if line.startswith(' '):
# code block due to github syntax
- continue
+ new_lines.append(line)
+ elif inline_matches and not inline_matches[0].isspace():
+ # need to not handle inline blocks as a text
+ for i, m in enumerate(inline_matches):
+ line = line.replace('`%s`' % m, '<inline_block>%s</inline_block>' % i)
+
+ line = self._handle_non_code(line)
+ for i, m in enumerate(inline_matches):
+ line = line.replace('<inline_block>%s</inline_block>' % i, inline_matches[i])
+
+ new_lines.append(line)
else:
new_lines.append(self._handle_non_code(line))
return new_lines
@@ -130,8 +138,4 @@ class GitHubMarkdownConverter(object):
return '<s>%s</s>' % m.group(1)
def _codeblock_syntax(self, text):
- return ' :::%s' % text
-
- def _convert_inline_codeblock(self, m):
- text = m.group(0)
- return '**%s**' % text
+ return '\n :::%s' % text
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/11e26216/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 e305943..e991382 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
@@ -196,13 +196,10 @@ def hello(name):
Hello
-<br>
-
:::python
def hello(name):
- print "Hello, " + name
+ print "Hello, " + name'''
-<br>'''
issue = {
'body': body,
'title': 'title',
@@ -234,14 +231,10 @@ def hello(name):
Hello
-<br>
-
:::python
def hello(name):
- print "Hello, " + name
+ print "Hello, " + name'''
-<br>
-'''
issue = {'comments_url': '/comments'}
extractor.iter_comments.return_value = [
{
[40/44] git commit: [#6656] ticket:437 OAuth flow in individual
github import controllers
Posted by jo...@apache.org.
[#6656] ticket:437 OAuth flow in individual github import controllers
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/ac8fa2c0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ac8fa2c0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ac8fa2c0
Branch: refs/heads/cj/6815
Commit: ac8fa2c06b2f902b0f3a4c1a8fd8ff1b109560d6
Parents: 0775036
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Oct 25 15:50:31 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Nov 13 20:46:25 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/__init__.py | 7 +++----
ForgeImporters/forgeimporters/github/code.py | 6 ++++--
ForgeImporters/forgeimporters/github/project.py | 2 +-
ForgeImporters/forgeimporters/github/tracker.py | 5 +++--
ForgeImporters/forgeimporters/github/wiki.py | 5 +++--
5 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ac8fa2c0/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index fb34e6b..58afba3 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -146,19 +146,18 @@ class GitHubProjectExtractor(base.ProjectExtractor):
class GitHubOAuthMixin(object):
'''Support for github oauth web application flow.'''
- def oauth_begin(self, controller_url):
- '''controller_url is absolute url, refers the controller you mixed this class in'''
+ def oauth_begin(self):
client_id = config.get('github_importer.client_id')
secret = config.get('github_importer.client_secret')
if not client_id or not secret:
return # GitHub app is not configured
if c.user.get_tool_data('GitHubProjectImport', 'token'):
return # token already exists, nothing to do
- redirect_uri = controller_url.rstrip('/') + '/oauth_callback'
+ redirect_uri = request.url.rstrip('/') + '/oauth_callback'
oauth = OAuth2Session(client_id, redirect_uri=redirect_uri)
auth_url, state = oauth.authorization_url('https://github.com/login/oauth/authorize')
session['github.oauth.state'] = state # Used in callback to prevent CSRF
- session['github.oauth.redirect'] = controller_url
+ session['github.oauth.redirect'] = request.url
session.save()
redirect(auth_url)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ac8fa2c0/ForgeImporters/forgeimporters/github/code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/code.py b/ForgeImporters/forgeimporters/github/code.py
index 4ce2183..6fdd0b4 100644
--- a/ForgeImporters/forgeimporters/github/code.py
+++ b/ForgeImporters/forgeimporters/github/code.py
@@ -30,6 +30,7 @@ from tg.decorators import (
)
from allura.lib.decorators import require_post
+from allura.lib import helpers as h
from allura.controllers import BaseController
from allura import model as M
@@ -39,7 +40,7 @@ from forgeimporters.base import (
ToolImporter,
ToolImportForm,
)
-from forgeimporters.github import GitHubProjectExtractor
+from forgeimporters.github import GitHubProjectExtractor, GitHubOAuthMixin
class GitHubRepoImportForm(ToolImportForm):
@@ -47,7 +48,7 @@ class GitHubRepoImportForm(ToolImportForm):
gh_user_name = fev.UnicodeString(not_empty=True)
-class GitHubRepoImportController(BaseController):
+class GitHubRepoImportController(BaseController, GitHubOAuthMixin):
def __init__(self):
self.importer = GitHubRepoImporter()
@@ -58,6 +59,7 @@ class GitHubRepoImportController(BaseController):
@with_trailing_slash
@expose('jinja:forgeimporters.github:templates/code/index.html')
def index(self, **kw):
+ self.oauth_begin()
return dict(importer=self.importer,
target_app=self.target_app)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ac8fa2c0/ForgeImporters/forgeimporters/github/project.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/project.py b/ForgeImporters/forgeimporters/github/project.py
index 29df780..2462617 100644
--- a/ForgeImporters/forgeimporters/github/project.py
+++ b/ForgeImporters/forgeimporters/github/project.py
@@ -53,7 +53,7 @@ class GitHubProjectImporter(base.ProjectImporter, GitHubOAuthMixin):
@with_trailing_slash
@expose(index_template)
def index(self, **kw):
- self.oauth_begin(h.absurl('/p/import_project/github/'))
+ self.oauth_begin()
return super(self.__class__, self).index(**kw)
@require_post()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ac8fa2c0/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index 288379b..cda1466 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -44,7 +44,7 @@ from ming.orm import session, ThreadLocalORMSession
from pylons import tmpl_context as c
from pylons import app_globals as g
-from . import GitHubProjectExtractor
+from . import GitHubProjectExtractor, GitHubOAuthMixin
from ..base import ToolImporter
from forgetracker.tracker_main import ForgeTrackerApp
from forgetracker import model as TM
@@ -57,7 +57,7 @@ class GitHubTrackerImportForm(ToolImportForm):
gh_user_name = fev.UnicodeString(not_empty=True)
-class GitHubTrackerImportController(BaseController):
+class GitHubTrackerImportController(BaseController, GitHubOAuthMixin):
def __init__(self):
self.importer = GitHubTrackerImporter()
@@ -69,6 +69,7 @@ class GitHubTrackerImportController(BaseController):
@with_trailing_slash
@expose('jinja:forgeimporters.github:templates/tracker/index.html')
def index(self, **kw):
+ self.oauth_begin()
return dict(importer=self.importer,
target_app=self.target_app)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ac8fa2c0/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index ce3214c..33801df 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -50,7 +50,7 @@ from forgeimporters.base import (
ToolImporter,
ToolImportForm,
)
-from forgeimporters.github import GitHubProjectExtractor
+from forgeimporters.github import GitHubProjectExtractor, GitHubOAuthMixin
from forgeimporters.github.utils import GitHubMarkdownConverter
from forgewiki import model as WM
from forgewiki.converters import mediawiki2markdown
@@ -74,7 +74,7 @@ class GitHubWikiImportForm(ToolImportForm):
tool_option = fev.UnicodeString(if_missing=u'')
-class GitHubWikiImportController(BaseController):
+class GitHubWikiImportController(BaseController, GitHubOAuthMixin):
def __init__(self):
self.importer = GitHubWikiImporter()
@@ -86,6 +86,7 @@ class GitHubWikiImportController(BaseController):
@with_trailing_slash
@expose('jinja:forgeimporters.github:templates/wiki/index.html')
def index(self, **kw):
+ self.oauth_begin()
return dict(importer=self.importer,
target_app=self.target_app)
[06/44] git commit: [#6622] ticket:435 Fix ticket regexs
Posted by jo...@apache.org.
[#6622] ticket:435 Fix ticket regexs
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d7ee1913
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d7ee1913
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d7ee1913
Branch: refs/heads/cj/6815
Commit: d7ee19139de1670d7295ddfc0a4bb96ec63a3927
Parents: f0e6117
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 16:29:07 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:55 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 6 ++--
ForgeImporters/forgeimporters/github/utils.py | 31 ++++++++++++++++++--
2 files changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d7ee1913/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 a0dfbcc..3ce8d29 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_utils.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -49,7 +49,7 @@ class TestGitHubMarkdownConverter(object):
text = ' #1'
assert_equal(self.conv.convert(text), ' #1')
- def test_convert_username_ticket(self):
+ def test_convert_user_ticket(self):
text = 'user#1'
result = self.conv.convert(text)
assert_equal(result, '[#1]')
@@ -59,7 +59,7 @@ class TestGitHubMarkdownConverter(object):
result = self.conv.convert(text)
assert_equal(result, 'another-user#1')
- def test_convert_username_repo_ticket(self):
+ def test_convert_user_repo_ticket(self):
text = 'user/project#1'
result = self.conv.convert(text)
assert_equal(result, '[p:mount:#1]')
@@ -67,7 +67,7 @@ class TestGitHubMarkdownConverter(object):
# Not a current project
text = 'user/p#1'
result = self.conv.convert(text)
- assert_equal(result, '[user/p#1](https://github.com/u/p/issues/1)')
+ assert_equal(result, '[user/p#1](https://github.com/user/p/issues/1)')
def test_convert_strikethrough(self):
text = '~~mistake~~'
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d7ee1913/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index defe391..da50c2d 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -9,13 +9,19 @@ class GitHubMarkdownConverter(object):
self.gh_base_url = u'https://github.com/'
def convert(self, text):
+ _re = re.compile(r'(\s|^)(\S+)/(\S+)#(\d+)(\s|$)')
+ text = _re.sub(self._convert_user_repo_ticket, text)
+
+ _re = re.compile(r'(\s|^)(\S+)#(\d+)(\s|$)')
+ text = _re.sub(self._convert_user_ticket, text)
+
_re = re.compile(r'(\S+\s+)(#\d+)')
text = _re.sub(self._convert_ticket, text)
- _re = re.compile(r'(\s|^)(.+)/(.+)@([0-9a-f]{40})(\s|$)')
+ _re = re.compile(r'(\s|^)(\S+)/(\S+)@([0-9a-f]{40})(\s|$)')
text = _re.sub(self._convert_user_repo_sha, text)
- _re = re.compile(r'(\s|^)(.+)@([0-9a-f]{40})(\s|$)')
+ _re = re.compile(r'(\s|^)(\S+)@([0-9a-f]{40})(\s|$)')
text = _re.sub(self._convert_user_sha, text)
_re = re.compile(r'(\s|^)([0-9a-f]{40})(\s|$)')
@@ -31,12 +37,33 @@ class GitHubMarkdownConverter(object):
def _gh_commit_url(self, project, sha, title):
return u'[%s](%s)' % (title, self.gh_base_url + project + '/commit/' + sha)
+ def _gh_ticket_url(self, project, tid, title):
+ return u'[%s](%s)' % (title, self.gh_base_url + project + '/issues/' + str(tid))
+
def _convert_sha(self, m):
return '%s[%s]%s' % (m.group(1), m.group(2)[:6], m.group(3))
def _convert_ticket(self, m):
return '%s[%s]' % m.groups()
+ def _convert_user_ticket(self, m):
+ user = m.group(2)
+ tid = m.group(3)
+ if self.gh_project.startswith(user + '/'):
+ return '%s[%s]%s' % (m.group(1), '#' + tid, m.group(4))
+ return m.group(0)
+
+ def _convert_user_repo_ticket(self, m):
+ 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))
+ title = project + '#' + tid
+ return ''.join([m.group(1),
+ self._gh_ticket_url(project, tid, title),
+ m.group(5)])
+
def _convert_user_sha(self, m):
user = m.group(2)
sha = m.group(3)
[28/44] git commit: [#6845] Handle issue X and rX references in GC
tracker importer
Posted by jo...@apache.org.
[#6845] Handle issue X and rX references in GC tracker importer
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/7ed59a15
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7ed59a15
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7ed59a15
Branch: refs/heads/cj/6815
Commit: 7ed59a15b5257a62ad42aea46482af2eaebe5dff
Parents: 1989f48
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Nov 8 23:11:59 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 19:15:29 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/google/__init__.py | 25 ++++++++++++++---
ForgeImporters/forgeimporters/google/tracker.py | 2 +-
.../tests/data/google/test-issue.html | 4 ++-
.../tests/google/functional/test_tracker.py | 6 ++++-
.../tests/google/test_extractor.py | 28 +++++++++++---------
.../forgeimporters/tests/google/test_tracker.py | 2 +-
6 files changed, 47 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7ed59a15/ForgeImporters/forgeimporters/google/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/__init__.py b/ForgeImporters/forgeimporters/google/__init__.py
index ae595e8..261b9f9 100644
--- a/ForgeImporters/forgeimporters/google/__init__.py
+++ b/ForgeImporters/forgeimporters/google/__init__.py
@@ -52,6 +52,25 @@ def _as_text(node, chunks=None):
_as_text(n, chunks)
return ''.join(chunks)
+def _as_markdown(tag):
+ fragments = []
+ for fragment in tag:
+ if getattr(fragment, 'name', None) == 'a':
+ href = urlparse(fragment['href'])
+ qs = parse_qs(href.query)
+ if not href.netloc and 'id' in qs:
+ fragment = '[%s](#%s)' % (fragment.text, qs['id'][0])
+ elif not href.netloc and 'r' in qs:
+ fragment = '[r%s]' % qs['r'][0]
+ else:
+ fragment = h.plain2markdown(fragment.text, preserve_multiple_spaces=True, has_html_entities=True)
+ elif getattr(fragment, 'name', None) == 'i':
+ fragment = '*%s*' % h.plain2markdown(fragment.text, preserve_multiple_spaces=True, has_html_entities=True)
+ else:
+ fragment = h.plain2markdown(str(fragment), preserve_multiple_spaces=True, has_html_entities=True)
+ fragments.append(fragment)
+ return ''.join(fragments).strip()
+
def csv_parser(page):
lines = page.readlines()
if not lines:
@@ -184,7 +203,7 @@ class GoogleCodeProjectExtractor(ProjectExtractor):
return bs.text
def get_issue_description(self):
- return _as_text(self.page.find(id='hc0').pre).strip()
+ return _as_markdown(self.page.find(id='hc0').pre)
def get_issue_created_date(self):
return self.page.find(id='hc0').find('span', 'date').get('title')
@@ -267,7 +286,7 @@ class Comment(object):
def __init__(self, tag):
self.author = UserLink(tag.find('span', 'author').find(True, 'userlink'))
self.created_date = tag.find('span', 'date').get('title')
- self.body = _as_text(tag.find('pre')).strip()
+ self.body = _as_markdown(tag.find('pre'))
self._get_updates(tag)
self.attachments = _get_attachments(tag)
@@ -287,7 +306,7 @@ class Comment(object):
u'{updates}'
).format(
author=self.author,
- body=h.plain2markdown(self.body, preserve_multiple_spaces=True, has_html_entities=True),
+ body=self.body,
updates='\n'.join(
'**%s** %s' % (k,v)
for k,v in self.updates.items()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7ed59a15/ForgeImporters/forgeimporters/google/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/tracker.py b/ForgeImporters/forgeimporters/google/tracker.py
index 59b50bc..080ea90 100644
--- a/ForgeImporters/forgeimporters/google/tracker.py
+++ b/ForgeImporters/forgeimporters/google/tracker.py
@@ -184,7 +184,7 @@ class GoogleCodeTrackerImporter(ToolImporter):
u'{body}').format(
creator=issue.get_issue_creator(),
owner=owner_line,
- body=h.plain2markdown(issue.get_issue_description(), preserve_multiple_spaces=True, has_html_entities=True),
+ body=issue.get_issue_description(),
)
ticket.add_multiple_attachments(issue.get_issue_attachments())
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7ed59a15/ForgeImporters/forgeimporters/tests/data/google/test-issue.html
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/data/google/test-issue.html b/ForgeImporters/forgeimporters/tests/data/google/test-issue.html
index 693ca1d..374c0e8 100644
--- a/ForgeImporters/forgeimporters/tests/data/google/test-issue.html
+++ b/ForgeImporters/forgeimporters/tests/data/google/test-issue.html
@@ -280,6 +280,8 @@ Test *Issue* for testing
if p.count > 5:
print "Not < 5 & != 5"
+References: <a href="/p/allura-google-importer/issues/detail?id=1">issue 1</a>, <a href="/p/allura-google-importer/source/detail?r=2">r2</a>
+
That's all
@@ -384,7 +386,7 @@ Test *comment* is a comment
<a name="c2" href="/p/allura-google-importer/issues/detail?id=6#c2">#2</a>
<a class="userlink" href="/u/101557263855536553789/">john...@gmail.com</a></span>
<pre>
-Another comment
+Another comment with references: <a href="/p/allura-google-importer/issues/detail?id=2">issue 2</a>, <a href="/p/allura-google-importer/source/detail?r=1">r1</a>
</pre>
</div>
<div class="cursor_off vt issuecomment" id="hc3">
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7ed59a15/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py b/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
index 528c2b6..2e52be6 100644
--- a/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/google/functional/test_tracker.py
@@ -125,6 +125,8 @@ class TestGCTrackerImporter(TestCase):
' if p\\.count > 5:\n'
' print "Not < 5 & \\!= 5"\n'
'\n'
+ 'References: [issue 1](#1), [r2]\n'
+ '\n'
'That\'s all'
)
self.assertEqual(ticket.status, 'Started')
@@ -178,6 +180,8 @@ class TestGCTrackerImporter(TestCase):
' if p.count > 5:\n'
' print "Not < 5 & \\!= 5"\n'
'\n'
+ 'References: [issue 1](#1), [r2]\n'
+ '\n'
'That\'s all'
)
@@ -217,7 +221,7 @@ class TestGCTrackerImporter(TestCase):
'text': (
'*Originally posted by:* [john...@gmail.com](http://code.google.com/u/101557263855536553789/)\n'
'\n'
- 'Another comment\n\n'
+ 'Another comment with references: [issue 2](#2), [r1]\n\n'
),
},
{
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7ed59a15/ForgeImporters/forgeimporters/tests/google/test_extractor.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/test_extractor.py b/ForgeImporters/forgeimporters/tests/google/test_extractor.py
index c2c800a..032e122 100644
--- a/ForgeImporters/forgeimporters/tests/google/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/google/test_extractor.py
@@ -170,22 +170,24 @@ class TestGoogleCodeProjectExtractor(TestCase):
self._p_soup.stop()
self.assertEqual(gpe.get_issue_summary(), 'Test "Issue"')
assert_equal(gpe.get_issue_description(),
- 'Test *Issue* for testing\n'
+ 'Test \\*Issue\\* for testing\n'
'\n'
- ' 1. Test List\n'
- ' 2. Item\n'
+ ' 1. Test List\n'
+ ' 2. Item\n'
'\n'
- '**Testing**\n'
+ '\\*\\*Testing\\*\\*\n'
'\n'
- ' * Test list 2\n'
- ' * Item\n'
+ ' \\* Test list 2\n'
+ ' \\* Item\n'
'\n'
- '# Test Section\n'
+ '\\# Test Section\n'
'\n'
- ' p = source.test_issue.post()\n'
- ' p.count = p.count *5 #* 6\n'
- ' if p.count > 5:\n'
- ' print "Not < 5 & != 5"\n'
+ ' p = source.test\\_issue.post\\(\\)\n'
+ ' p.count = p.count \\*5 \\#\\* 6\n'
+ ' if p.count > 5:\n'
+ ' print "Not < 5 & \\!= 5"\n'
+ '\n'
+ 'References: [issue 1](#1), [r2]\n'
'\n'
'That\'s all'
)
@@ -252,7 +254,7 @@ class TestGoogleCodeProjectExtractor(TestCase):
'author.name': 'john...@gmail.com',
'author.url': 'http://code.google.com/u/101557263855536553789/',
'created_date': 'Thu Aug 8 15:35:15 2013',
- 'body': 'Test *comment* is a comment',
+ 'body': 'Test \\*comment\\* is a comment',
'updates': {'Status:': 'Started', 'Labels:': '-OpSys-Linux OpSys-Windows'},
'attachments': ['at2.txt'],
},
@@ -260,7 +262,7 @@ class TestGoogleCodeProjectExtractor(TestCase):
'author.name': 'john...@gmail.com',
'author.url': 'http://code.google.com/u/101557263855536553789/',
'created_date': 'Thu Aug 8 15:35:34 2013',
- 'body': 'Another comment',
+ 'body': 'Another comment with references: [issue 2](#2), [r1]',
'updates': {},
'attachments': [],
},
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7ed59a15/ForgeImporters/forgeimporters/tests/google/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/test_tracker.py b/ForgeImporters/forgeimporters/tests/google/test_tracker.py
index 6e877f6..604eafd 100644
--- a/ForgeImporters/forgeimporters/tests/google/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/google/test_tracker.py
@@ -166,7 +166,7 @@ class TestTrackerImporter(TestCase):
dt.strptime.side_effect = lambda s,f: s
importer.process_fields(ticket, issue)
self.assertEqual(ticket.summary, 'summary')
- self.assertEqual(ticket.description, '*Originally created by:* creator\n*Originally owned by:* owner\n\nmy \*description\* fool')
+ self.assertEqual(ticket.description, '*Originally created by:* creator\n*Originally owned by:* owner\n\nmy *description* fool')
self.assertEqual(ticket.status, 'status')
self.assertEqual(ticket.created_date, 'created_date')
self.assertEqual(ticket.mod_date, 'mod_date')
[16/44] git commit: [#6622] ticket:435 Convert markdown in wiki
Posted by jo...@apache.org.
[#6622] ticket:435 Convert markdown in wiki
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/23db53ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/23db53ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/23db53ae
Branch: refs/heads/cj/6815
Commit: 23db53ae5e8a8fed6796ecc5529468f009985ae8
Parents: 88365c6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 16:52:09 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:56 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_wiki.py | 31 +++++++++++++++++---
ForgeImporters/forgeimporters/github/wiki.py | 11 +++++--
2 files changed, 35 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/23db53ae/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 50c905d..ea54b10 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -28,6 +28,7 @@ from allura.tests import TestController
from allura.tests.decorators import with_tool, without_module
from alluratest.controller import setup_basic_test
from forgeimporters.github.wiki import GitHubWikiImporter
+from forgeimporters.github.utils import GitHubMarkdownConverter
# important to be distinct from 'test' which ForgeWiki uses, so that the tests can run in parallel and not clobber each other
@@ -290,6 +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')
f = importer.convert_markup
source = u'''Look at [[this page|Some Page]]
@@ -299,12 +301,33 @@ Our website is [[http://sf.net]].
'[[Escaped Tag]]
-[External link to the wiki page](https://github.com/a/b/wiki/Page)
+```python
+codeblock
+```
-[External link](https://github.com/a/b/issues/1)'''
+ticket #1
- # markdown should be untouched
- assert_equal(f(source, 'test.md'), source)
+#1 header
+
+sha aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'''
+ result = u'''Look at [this page](Some Page)
+
+More info at: [MoreInfo] [Even More Info]
+
+Our website is <http://sf.net>.
+
+[[Escaped Tag]]
+
+~~~~
+codeblock
+~~~~
+
+ticket [#1]
+
+#1 header
+
+sha [aaaaaa]'''
+ assert_equal(f(source, 'test.md').strip(), result)
assert_equal(f(u'h1. Hello', 't.textile').strip(), u'# Hello')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/23db53ae/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 4bf796c..1290224 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -155,6 +155,12 @@ 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,
+ )
try:
M.session.artifact_orm_session._get().skip_mod_date = True
with h.push_config(c, app=self.app):
@@ -265,9 +271,8 @@ class GitHubWikiImporter(ToolImporter):
"""
name, ext = os.path.splitext(filename)
if ext in self.markdown_exts:
- text = GitHubMarkdownConverter.convert(text)
- return text
- #return self.convert_gollum_tags(text)
+ text = self.github_markdown_converter.convert(text)
+ return self.convert_gollum_tags(text)
try:
import html2text
[11/44] git commit: [#6622] ticket:435 Move github-markdown
conversion methods to separate class
Posted by jo...@apache.org.
[#6622] ticket:435 Move github-markdown conversion methods to separate class
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/44a7d0a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/44a7d0a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/44a7d0a1
Branch: refs/heads/cj/6815
Commit: 44a7d0a11c2262fc2c46709f9f73df2a338c769b
Parents: 18b4e34
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 14:12:28 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:55 2013 +0000
----------------------------------------------------------------------
.../forgeimporters/github/tests/test_utils.py | 39 ++++++++++++++++
.../forgeimporters/github/tests/test_wiki.py | 36 ---------------
ForgeImporters/forgeimporters/github/utils.py | 47 ++++++++++++++++++++
ForgeImporters/forgeimporters/github/wiki.py | 6 ++-
4 files changed, 90 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44a7d0a1/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
new file mode 100644
index 0000000..8711312
--- /dev/null
+++ b/ForgeImporters/forgeimporters/github/tests/test_utils.py
@@ -0,0 +1,39 @@
+from nose.tools import assert_equal
+
+from forgeimporters.github.utils import GitHubMarkdownConverter
+
+
+class TestGitHubMarkdownConverter(object):
+
+ def setUp(self):
+ self.conv = GitHubMarkdownConverter
+
+ def test_convert_sha_github_markup(self):
+ text = 'SHA: 16c999e8c71134401a78d4d46435517b2271d6ac'
+ result = self.conv.convert(text)
+ assert_equal(result, 'SHA: [16c999]')
+
+ def test_convert_user_sha_github_markup(self):
+ text = 'User@SHA: mojombo@16c999e8c71134401a78d4d46435517b2271d6ac'
+ result = self.conv.convert(text)
+ assert_equal(result, 'User@SHA:[16c999]')
+
+ def test_convert_user_repo_sha_github_markup(self):
+ text = 'User/Repository@SHA: mojombo/github-flavored-markdown@16c999e8c71134401a78d4d46435517b2271d6ac'
+ result = self.conv.convert(text)
+ assert_equal(result, 'User/Repository@SHA: [16c999]')
+
+ def test_convert_ticket_github_markup(self):
+ text = 'Ticket: #1'
+ result = self.conv.convert(text)
+ assert_equal(result, 'Ticket: [#1]')
+
+ def test_convert_username_ticket_github_markup(self):
+ text = 'User#Num: user#1'
+ result = self.conv.convert(text)
+ assert_equal(result, 'User#Num: [#1]')
+
+ def test_convert_username_repo_ticket_github_markup(self):
+ text = 'User/Repository#Num: user/repo#1'
+ result = self.conv.convert(text)
+ assert_equal(result, 'User/Repository#Num: [#1]')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44a7d0a1/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 bb2a383..50c905d 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -479,42 +479,6 @@ some text and **[Tips n' Tricks]**
result = u'<p><strong>[[this checklist|Troubleshooting]]</strong></p>'
assert_equal(f(source, 't.textile').strip(), result)
- def test_convert_sha_github_markup(self):
- html = 'SHA: 16c999e8c71134401a78d4d46435517b2271d6ac'
- importer = GitHubWikiImporter()
- result = importer.convert_github_markup(html)
- assert_equal(result, 'SHA: [16c999]')
-
- def test_convert_user_sha_github_markup(self):
- html = 'User@SHA: mojombo@16c999e8c71134401a78d4d46435517b2271d6ac'
- importer = GitHubWikiImporter()
- result = importer.convert_github_markup(html)
- assert_equal(result, 'User@SHA:[16c999]')
-
- def test_convert_user_repo_sha_github_markup(self):
- html = 'User/Repository@SHA: mojombo/github-flavored-markdown@16c999e8c71134401a78d4d46435517b2271d6ac'
- importer = GitHubWikiImporter()
- result = importer.convert_github_markup(html)
- assert_equal(result, 'User/Repository@SHA: [16c999]')
-
- def test_convert_ticket_github_markup(self):
- html = 'Ticket: #1'
- importer = GitHubWikiImporter()
- result = importer.convert_github_markup(html)
- assert_equal(result, 'Ticket: [#1]')
-
- def test_convert_username_ticket_github_markup(self):
- html = 'User#Num: user#1'
- importer = GitHubWikiImporter()
- result = importer.convert_github_markup(html)
- assert_equal(result, 'User#Num: [#1]')
-
- def test_convert_username_repo_ticket_github_markup(self):
- html = 'User/Repository#Num: user/repo#1'
- importer = GitHubWikiImporter()
- result = importer.convert_github_markup(html)
- assert_equal(result, 'User/Repository#Num: [#1]')
-
class TestGitHubWikiImportController(TestController, TestCase):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44a7d0a1/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
new file mode 100644
index 0000000..c095f81
--- /dev/null
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -0,0 +1,47 @@
+import re
+
+
+class GitHubMarkdownConverter(object):
+
+ @classmethod
+ def convert(cls, text):
+ _re = re.compile('\S*(#\d+)')
+ text = _re.sub(cls._convert_ticket, text)
+
+ _re = re.compile('\S*/\S*@(\w{40})')
+ text = _re.sub(cls._convert_user_repo_sha, text)
+
+ _re = re.compile('\s\S*@(\w{40})')
+ text = _re.sub(cls._convert_user_sha, text)
+
+ _re = re.compile(': (\w{40})')
+ text = _re.sub(cls._convert_sha, text)
+ _re = re.compile('~~(.*)~~',)
+ text = _re.sub(cls._convert_strikethrough, text)
+ _re = re.compile(r'```\w*(.*)```', re.DOTALL)
+ text = _re.sub(cls._convert_codeblock, text)
+ return text
+
+ @classmethod
+ def _convert_sha(cls, match):
+ return ': [%s]' % match.group(1)[:6]
+
+ @classmethod
+ def _convert_ticket(cls, match):
+ return '[%s]' % match.group(1)
+
+ @classmethod
+ def _convert_user_sha(cls, match):
+ return '[%s]' % (match.group(1)[:6])
+
+ @classmethod
+ def _convert_user_repo_sha(cls, match):
+ return '[%s]' % (match.group(1)[:6])
+
+ @classmethod
+ def _convert_strikethrough(cls, match):
+ return '<s>%s</s>' % match.group(1)
+
+ @classmethod
+ def _convert_codeblock(cls, match):
+ return '\n~~~~%s~~~~\n'% match.group(1)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/44a7d0a1/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index f95ba44..4bf796c 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -51,6 +51,7 @@ from forgeimporters.base import (
ToolImportForm,
)
from forgeimporters.github import GitHubProjectExtractor
+from forgeimporters.github.utils import GitHubMarkdownConverter
from forgewiki import model as WM
from forgewiki.converters import mediawiki2markdown
@@ -264,7 +265,9 @@ class GitHubWikiImporter(ToolImporter):
"""
name, ext = os.path.splitext(filename)
if ext in self.markdown_exts:
- return self.convert_github_markup(text)
+ text = GitHubMarkdownConverter.convert(text)
+ return text
+ #return self.convert_gollum_tags(text)
try:
import html2text
@@ -394,7 +397,6 @@ class GitHubWikiImporter(ToolImporter):
a.setString(new_prefix + new_page)
return unicode(soup)
-
def _prepare_textile_text(self, text):
# need to convert lists properly
text_lines = text.splitlines()
[10/44] git commit: [#6622] ticket:435 Convert github mardown in
tickets & comments
Posted by jo...@apache.org.
[#6622] ticket:435 Convert github mardown in tickets & comments
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b6f29e90
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b6f29e90
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b6f29e90
Branch: refs/heads/cj/6815
Commit: b6f29e90a3c187eea388dfd776a472b489e11a76
Parents: 44a7d0a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 14 14:30:29 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Nov 13 17:16:55 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/tracker.py | 5 +-
ForgeImporters/forgeimporters/github/utils.py | 2 +-
.../forgeimporters/tests/github/test_tracker.py | 65 ++++++++++++++++++++
3 files changed, 69 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b6f29e90/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index ebed4ed..c3c7ab4 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -49,6 +49,7 @@ from ..base import ToolImporter
from forgetracker.tracker_main import ForgeTrackerApp
from forgetracker import model as TM
from forgeimporters.base import ToolImportForm
+from forgeimporters.github.utils import GitHubMarkdownConverter
class GitHubTrackerImportForm(ToolImportForm):
@@ -169,7 +170,7 @@ class GitHubTrackerImporter(ToolImporter):
u'{body}').format(
creator=self.get_user_link(issue['user']['login']),
owner=owner_line,
- body=body,
+ body=GitHubMarkdownConverter().convert(body),
)
ticket.labels = [label['name'] for label in issue['labels']]
@@ -181,7 +182,7 @@ class GitHubTrackerImporter(ToolImporter):
self.get_user_link(comment['user']['login']))
body = posted_by + body
p = ticket.discussion_thread.add_post(
- text = body,
+ text = GitHubMarkdownConverter().convert(body),
ignore_security = True,
timestamp = self.parse_datetime(comment['created_at']),
)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b6f29e90/ForgeImporters/forgeimporters/github/utils.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/utils.py b/ForgeImporters/forgeimporters/github/utils.py
index c095f81..ab66157 100644
--- a/ForgeImporters/forgeimporters/github/utils.py
+++ b/ForgeImporters/forgeimporters/github/utils.py
@@ -44,4 +44,4 @@ class GitHubMarkdownConverter(object):
@classmethod
def _convert_codeblock(cls, match):
- return '\n~~~~%s~~~~\n'% match.group(1)
+ return '~~~~%s~~~~'% match.group(1)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b6f29e90/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 262ff1e..7cd3c90 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
@@ -179,3 +179,68 @@ class TestTrackerImporter(TestCase):
text='- **assigned_to**: [luke](https://github.com/luke)',
timestamp=datetime(2013, 9, 12, 10, 14, 0),
ignore_security=True))
+
+ def test_github_markdown_converted_in_description(self):
+ ticket = mock.Mock()
+ body = '''Hello
+
+```python
+def hello(name):
+ print "Hello, " + name
+```'''
+ body_converted = '''*Originally created by:* [creator](https://github.com/creator)
+*Originally owned by:* [owner](https://github.com/owner)
+
+Hello
+
+~~~~
+def hello(name):
+ print "Hello, " + name
+~~~~'''
+ issue = {
+ 'body': body,
+ 'title': 'title',
+ 'state': 'New',
+ 'created_at': 'created_at',
+ 'updated_at': 'updated_at',
+ 'assignee': {'login': 'owner'},
+ 'user': {'login': 'creator'},
+ 'labels': [{'name': 'first'}, {'name': 'second'}],
+ }
+ importer = tracker.GitHubTrackerImporter()
+ with mock.patch.object(tracker, 'datetime') as dt:
+ dt.strptime.side_effect = lambda s,f: s
+ importer.process_fields(ticket, issue)
+ self.assertEqual(ticket.description.strip(), body_converted.strip())
+
+ def test_github_markdown_converted_in_comments(self):
+ ticket = mock.Mock()
+ extractor = mock.Mock()
+ body = '''Hello
+
+```python
+def hello(name):
+ print "Hello, " + name
+```'''
+ body_converted = '''*Originally posted by:* [me](https://github.com/me)
+Hello
+
+~~~~
+def hello(name):
+ print "Hello, " + name
+~~~~'''
+ issue = {'comments_url': '/comments'}
+ extractor.iter_comments.return_value = [
+ {
+ 'body': body,
+ 'created_at': '2013-08-26T16:57:53Z',
+ 'user': {'login': 'me'},
+ }
+ ]
+ importer = tracker.GitHubTrackerImporter()
+ importer.process_comments(extractor, ticket, issue)
+ self.assertEqual(ticket.discussion_thread.add_post.call_args_list[0], mock.call(
+ text=body_converted,
+ timestamp=datetime(2013, 8, 26, 16, 57, 53),
+ ignore_security=True,
+ ))