Commits

Tetsuya Morimoto  committed 57e0d4a

fixed to pick up reference ticket ID in comment from 2nd line

  • Participants
  • Parent commits 16df951

Comments (0)

Files changed (1)

File ticketref/utils.py

 import re
 
 _RE_REFS_WITH_IDS = re.compile(r"""
-    ^.*?(?P<ref_text>(ref.*?)\s+(\#\d+[,|\s]*){1,})
-""", re.U | re.X)
+    (?P<ref_text>(ref.*?)\s+(\#\d+[,|\s]*){1,})
+""", re.U | re.M | re.X)
 
 def get_refs_in_comment(comment):
     """ pick out reference text and convert text to ids
     set([])
     >>> get_refs_in_comment(u"reference#1 #3, #5")
     set([1, 3, 5])
+    >>> get_refs_in_comment(u"adding.\\nrefs #1")
+    set([1])
+    >>> get_refs_in_comment(u"adding.\\nrefs #1 #3, #5")
+    set([1, 3, 5])
+    >>> get_refs_in_comment(u"adding.\\nsecond\\nrefs #2")
+    set([2])
     """
     ref_ids = set([])
-    match = re.match(_RE_REFS_WITH_IDS, comment)
+    match = re.search(_RE_REFS_WITH_IDS, comment)
     if match:
         ref_text = match.groupdict().get("ref_text")
         ref_ids = get_ref_ids_in_comment(ref_text)