#2533 Remove the front whitespace from the commit markdown regex
Merged 6 years ago by pingou. Opened 6 years ago by cverna.
cverna/pagure fix_2082  into  master

file modified
+3 -3
@@ -53,7 +53,7 @@ 

      '#(?P<id>[\w]{40})'

  IMPLICIT_ISSUE_RE = r'[^|\w](?<!\w)#([0-9]+)'

  IMPLICIT_PR_RE = r'[^|\w](?<!\w)PR#([0-9]+)'

- IMPLICIT_COMMIT_RE = r'[^|\w](?<![>\w#])([a-f0-9]{7,40})'

+ IMPLICIT_COMMIT_RE = r'(?<![<\w#])([a-f0-9]{7,40})'

  STRIKE_THROUGH_RE = r'~~(.*?)~~'

  

  
@@ -236,7 +236,7 @@ 

          """ When the pattern matches, update the text. """

  

          githash = markdown.util.AtomicString(m.group(2))

-         text = ' %s' % githash

+         text = '%s' % githash

          try:

              root = flask.request.url_root

              url = flask.request.url
@@ -259,7 +259,7 @@ 

                  namespace=namespace,

                  pattern=repo) \

                  and _commit_exists(user, namespace, repo, githash):

-             return _obj_anchor_tag(user, namespace, repo, githash, text[:8])

+             return _obj_anchor_tag(user, namespace, repo, githash, text[:7])

  

          return text

  

@@ -677,15 +677,15 @@ 

              '<p>Cf commit 936435</p>',

              # 'Cf commit 9364354',

              #'<p>Cf commit 9364354</p>',

-             '<p>Cf commit<a href="/test/c/9364354" '

-             'title="Commit 9364354"> 9364354</a></p>',

+             '<p>Cf commit <a href="/test/c/9364354" '

+             'title="Commit 9364354">9364354</a></p>',

              # 'Cf commit 9364354a',

-             '<p>Cf commit<a href="/test/c/9364354a" '

-             'title="Commit 9364354a"> 9364354</a></p>',

+             '<p>Cf commit <a href="/test/c/9364354a" '

+             'title="Commit 9364354a">9364354</a></p>',

              # 'Cf commit 9364354a4555ba17aa60f0dc844d70b74eb1aecd',

-             '<p>Cf commit<a href="/test/c/9364354a4555ba17aa60f0dc844d70b74eb1aecd" '

+             '<p>Cf commit <a href="/test/c/9364354a4555ba17aa60f0dc844d70b74eb1aecd" '

              'title="Commit 9364354a4555ba17aa60f0dc844d70b74eb1aecd"'

-             '> 9364354</a></p>',

+             '>9364354</a></p>',

          ]

  

          with pagure.APP.app_context():
@@ -752,7 +752,7 @@ 

          first_commit = repo.revparse_single('HEAD')

  

          text = 'Cf commit %s' % first_commit.oid.hex

-         exp = '<p>Cf commit<a href="/test/c/{0}" title="Commit {0}"> {1}'\

+         exp = '<p>Cf commit <a href="/test/c/{0}" title="Commit {0}">{1}'\

          '</a></p>'.format(first_commit.oid.hex, first_commit.oid.hex[:7])

  

          with pagure.APP.app_context():

This commit remove the not needed whitespace lookup from the custom
regex to render the commit hash using the markdown processor.

Fixes #2082

Signed-off-by: Clement Verna cverna@tutanota.com

rebased

6 years ago

Pull-Request has been merged by pingou

6 years ago