allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [07/44] git commit: [#6622] ticket:435 Fix user@sha regex
Date Wed, 13 Nov 2013 22:57:27 GMT
[#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 <jetmind2@gmail.com>
Authored: Mon Oct 14 16:16:29 2013 +0300
Committer: Dave Brondsema <dbrondsema@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))


Mime
View raw message