def test_parse_commit_msg(self): msg = """cmt subject body line 1 body line 2 metakey: metavalue author_date: 123 """ subject, metadatas = indexer.parse_commit_msg(msg) self.assertEqual(subject, 'cmt subject') self.assertTrue(len(metadatas) == 0) msg = """cmt subject body line 1 body line 2 Fix: metavalue Co-authored-by: metavalue2 """ subject, metadatas = indexer.parse_commit_msg(msg) self.assertEqual(subject, 'cmt subject') self.assertIn(('fixes-bug', 'metavalue'), metadatas) self.assertIn(('co-authored-by', 'metavalue2'), metadatas) self.assertTrue(len(metadatas) == 2) msg = """cmt subject body line 1. nokey: novalue Acked-By: metavalue body line 2 """ subject, metadatas = indexer.parse_commit_msg(msg) self.assertEqual(subject, 'cmt subject') self.assertIn(('acked-by', 'metavalue'), metadatas) self.assertTrue(len(metadatas) == 1) msg = """cmt subject body line 1 body line 2 http://metavalue """ subject, metadatas = indexer.parse_commit_msg(msg) self.assertEqual(subject, 'cmt subject') self.assertTrue(len(metadatas) == 0) msg = """Implement feature bp-feature-cool This patch implement blueprint bp-feature-cool. Also it add the documentation of the feature. I included the fix for the bug bz16 as it was releated. body line 2 http://metavalue """ p1 = re.compile('.*(blueprint) ([^ .]+).*') p2 = re.compile('.*(bug) ([^ .]+).*') parsers = [p1, p2] subject, metadatas = indexer.parse_commit_msg( msg, extra_parsers=parsers) self.assertEqual(subject, 'Implement feature bp-feature-cool') self.assertIn(('blueprint', 'bp-feature-cool'), metadatas) self.assertIn(('bug', 'bz16'), metadatas) self.assertTrue(len(metadatas) == 2)