def make_commit_message(record): s = record['message'] module = record['module'] # NOTE(aostapenko) Keeping default value here not to brake links # with existing storage data gerrit_hostname = record.get('gerrit_hostname', 'review.opendev.org') s = utils.format_text(s) # insert links s = re.sub( re.compile('(blueprint\s+)([\w-]+)', flags=re.IGNORECASE), r'\1<a href="https://blueprints.launchpad.net/' + module + r'/+spec/\2" class="ext_link">\2</a>', s) s = re.sub( re.compile('(bug[\s#:]*)([\d]{5,7})', flags=re.IGNORECASE), r'\1<a href="https://bugs.launchpad.net/bugs/\2" ' r'class="ext_link">\2</a>', s) # NOTE(aostapenko) Setting http here as it's common practice to redirect # http -> https, but not vice versa s = re.sub( r'\s+(I[0-9a-f]{40})', r' <a href="http://%s/#/q/\1" ' % gerrit_hostname + r'class="ext_link">\1</a>', s) s = utils.unwrap_text(s) return s
def make_commit_message(record): s = record['message'] s = utils.format_text(s) # insert links s = re.sub( re.compile('(bug[\s#:]*)([\d]{5,7})', flags=re.IGNORECASE), r'\1<a href="https://bugs.launchpad.net/bugs/\2" ' r'class="ext_link">\2</a>', s) s = re.sub( r'\s+(I[0-9a-f]{40})', r' <a href="https://review.openstack.org/#q,\1,n,z" ' r'class="ext_link">\1</a>', s) s = utils.unwrap_text(s) return s
def make_commit_message(record): s = record['message'] module = record['module'] s = utils.format_text(s) # insert links s = re.sub(re.compile('(blueprint\s+)([\w-]+)', flags=re.IGNORECASE), r'\1<a href="https://blueprints.launchpad.net/' + module + r'/+spec/\2" class="ext_link">\2</a>', s) s = re.sub(re.compile('(bug[\s#:]*)([\d]{5,7})', flags=re.IGNORECASE), r'\1<a href="https://bugs.launchpad.net/bugs/\2" ' r'class="ext_link">\2</a>', s) s = re.sub(r'\s+(I[0-9a-f]{40})', r' <a href="https://review.openstack.org/#q,\1,n,z" ' r'class="ext_link">\1</a>', s) s = utils.unwrap_text(s) return s
def make_commit_message(record): s = record['message'] module = record['module'] # NOTE(aostapenko) Keeping default value here not to brake links # with existing storage data gerrit_hostname = record.get('gerrit_hostname', 'review.openstack.org') s = utils.format_text(s) # insert links s = re.sub(re.compile('(blueprint\s+)([\w-]+)', flags=re.IGNORECASE), r'\1<a href="https://blueprints.launchpad.net/' + module + r'/+spec/\2" class="ext_link">\2</a>', s) s = re.sub(re.compile('(bug[\s#:]*)([\d]{5,7})', flags=re.IGNORECASE), r'\1<a href="https://bugs.launchpad.net/bugs/\2" ' r'class="ext_link">\2</a>', s) # NOTE(aostapenko) Setting http here as it's common practice to redirect # http -> https, but not vice versa s = re.sub(r'\s+(I[0-9a-f]{40})', r' <a href="http://%s/#/q/\1" ' % gerrit_hostname + r'class="ext_link">\1</a>', s) s = utils.unwrap_text(s) return s
def test_unwrap(self): original = 'Lorem ipsum. Dolor\nsit amet.\n Lorem\n ipsum.\ndolor!\n' expected = 'Lorem ipsum. Dolor sit amet.\n Lorem\n ipsum.\ndolor!' self.assertEqual(expected, utils.unwrap_text(original))